P
Piet Linden
I'm using Access 2002 and Word 2002 (Word 10)
I'm doing this from Access, if it matters. I'm opening a recordset
and using GetString to convert it to a delimited string. Once that's
done, I'm stuffing that into a cell in a Word table. I then want to
convert the delimited string in the cell to a table. It almost works
but I get a 1-row by 2-column table at the top of my Table Cell in
Word. What do I need to do to fix that?
Here's the code... I'm basically passing the contents of an Access
table to Word. (It's a small table!)
Get the data:
Private Sub cmdWriteWord_Click()
' This works as is.
' Date created: 2/8/2009 1:46:56 AM
' Purpose: Writes a single recordset to a cell in a word document
and converts it to a table.
Dim rsResult As ADODB.Recordset
Dim strResult As String
Dim strHeader As String
Dim intField As Integer
Set rsResult = New ADODB.Recordset
rsResult.Open "TEMP_XTB_RESULTS", CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly
For intField = 0 To rsResult.Fields.Count - 1
If intField > 0 Then
strHeader = strHeader & vbTab & rsResult.Fields
(intField).Name
Else
strHeader = rsResult.Fields(intField).Name
End If
Next intField
strResult = rsResult.GetString(adClipString, -1, vbTab, vbCrLf,
"")
strResult = strHeader & vbCrLf & strResult
Call WriteWord(Me.txtWordFile, 3, 3, strResult)
rsResult.Close
Set rsResult = Nothing
MsgBox "Job's done..."
End Sub
Anything noticeably wrong? I sure can't figure it out! Thanks!
Pieter
I'm doing this from Access, if it matters. I'm opening a recordset
and using GetString to convert it to a delimited string. Once that's
done, I'm stuffing that into a cell in a Word table. I then want to
convert the delimited string in the cell to a table. It almost works
but I get a 1-row by 2-column table at the top of my Table Cell in
Word. What do I need to do to fix that?
Here's the code... I'm basically passing the contents of an Access
table to Word. (It's a small table!)
Get the data:
Private Sub cmdWriteWord_Click()
' This works as is.
' Date created: 2/8/2009 1:46:56 AM
' Purpose: Writes a single recordset to a cell in a word document
and converts it to a table.
Dim rsResult As ADODB.Recordset
Dim strResult As String
Dim strHeader As String
Dim intField As Integer
Set rsResult = New ADODB.Recordset
rsResult.Open "TEMP_XTB_RESULTS", CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly
For intField = 0 To rsResult.Fields.Count - 1
If intField > 0 Then
strHeader = strHeader & vbTab & rsResult.Fields
(intField).Name
Else
strHeader = rsResult.Fields(intField).Name
End If
Next intField
strResult = rsResult.GetString(adClipString, -1, vbTab, vbCrLf,
"")
strResult = strHeader & vbCrLf & strResult
Call WriteWord(Me.txtWordFile, 3, 3, strResult)
rsResult.Close
Set rsResult = Nothing
MsgBox "Job's done..."
End Sub
Anything noticeably wrong? I sure can't figure it out! Thanks!
Pieter