possible to copy/fill Bookmarks with VBA dynamically ?

M

Martin_Maha

Hello!

My Problem is, that i have to fill a Word Document(Template) with DataBase
Data...
I Found out how to set Bookmarks in the Document and correctly fill them with
the Data from the DB.

Now the question :
Is there a way to define Bookmarks in the Template, lets say in one row in a
table
and fill this table according to the length of my DataBase data ? (Copy the
row WITH
the Bookmars and add it to the table as many times as i need it)

Cheers Martin
 
G

Greg Maxey

Martin,

If your are writing DB data to a table then you shouldn't need bookmarks.
Just reference the cell location. For example. This code writes the cell
reference to each cell in a table.

Sub ScratchMacro()
Dim oTbl As Word.Table
Dim i As Long
Dim j As Long
Set oTbl = ActiveDocument.Tables(1)
For i = 1 To oTbl.Rows.Count
For j = 1 To oTbl.Columns.Count
oTbl.Cell(i, j).Range.Text = "Cell location" & i & " " & j
Next j
Next i
'If you have more DB records than the table size then add a row for each
record
oTbl.Rows.Add
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top