I posted this in the VB 5 & 6 forum but thought that I may get better results here. Here is my code:
What I would like to do is have the count fill across and not down in the table so I can fit more of the count on one page. For example:
STATE COUNT STATE COUNT STATE COUNT
AL 50 AK 50 AR 50
AZ 50 PA 50 OH 50
Also, could someone shed so light on how to add multiple tables with the method used above? Thanks.
Swi
Code:
With rs
.CursorLocation = adUseServer
.Open "SELECT [STATE], COUNT(*) AS [QUANTITY] FROM [" & FileName & "]" & _
"GROUP BY [STATE]", conn, adOpenForwardOnly, adLockReadOnly, adCmdText
If .BOF And .EOF Then
Else
' Create an instance of Word
Set oWord = New Word.Application 'CreateObject("Word.Application")
' Show Word to the user
oWord.Visible = False
' Add a new, blank document
Set oDoc = oWord.Documents.Add
' Get the current document's range object
Set oRange = oDoc.Range
' Use GetString to return the recordset as a string
sTemp = rs.GetString(adClipString, -1, vbTab)
' Insert a heading on the string
sTemp = "State" & vbTab & "Quantity" & vbCrLf & sTemp
' Insert the data into the Word document
oRange.Text = sTemp
' Convert the text to a table and format the table
oRange.ConvertToTable vbTab, , , , wdTableFormatColorful2
End If
.Close
End With
What I would like to do is have the count fill across and not down in the table so I can fit more of the count on one page. For example:
STATE COUNT STATE COUNT STATE COUNT
AL 50 AK 50 AR 50
AZ 50 PA 50 OH 50
Also, could someone shed so light on how to add multiple tables with the method used above? Thanks.
Swi