Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

possible to copy/fill Bookmarks with VBA dynamically ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin_Maha - 05 Sep 2007 10:24 GMT
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
Greg Maxey - 05 Sep 2007 10:48 GMT
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

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hello!
>
[quoted text clipped - 14 lines]
>
> Cheers Martin
Martin_Maha - 05 Sep 2007 11:18 GMT
Thx for the quick reply Greg,

this should(could) fix my Problem!

M.

> Martin,
>
[quoted text clipped - 35 lines]
> >
> > Cheers Martin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.