Hi Cadey,
Following is the code which fill a single row in the word template. Before running this example create a template and store it in a proper position (Word template). This template should carry a table with number of rows/columns with proper text (template text). In my example i've used ~First~ and ~Last~ words inside my table(row/cell). I am replacing that value with database value. U have got access to all word utilities thru
vb.
I don't think is there any possiblity to create table from
vb. Anyway try to do the same and let me know once u have acheived it.
Enjoy coding
Cheers
Prasanna
Dim mobjDoc As Word.Document
Dim con As ADODB.Connection
Dim res As New ADODB.Recordset
Dim strvalue As String
Dim rngRange As Word.Range
Dim objWordApp As Word.Application
mstrReportTemplate = "c:\Test\" & "MyDoc.doc"
Set mobjDoc = GetObject(mstrReportTemplate, "word.document")
mobjDoc.Activate
Documents.Open ("c:\Test\MyDoc.doc")
Documents("MyDoc.doc").Activate
Set con = CreateObject("ADODB.Connection")
con.Open "DSN=staples;UID=real_Dev;PWD=its"
res.CursorType = adOpenForwardOnly
res.ActiveConnection = con
res.Open "select co_tnt from res_site_Addl_inf where site_id='0031AZ'", con, , adLockOptimistic
While Not res.EOF
strFirstName = res.Fields(0)
strLastName = res.Fields(1)
res.MoveNext
Wend
Set rngRange = mobjDoc.Tables(1).Cell(0, 0).Range
rngHeading.Find.Execute FindText:="~First~", ReplaceWith:=strFirstName
Set rngRange = mobjDoc.Tables(1).Cell(0, 1).Range
rngRange.Find.Execute FindText:="~AFTER~", ReplaceWith:=strLastName
....