Populate word document

G

Guest

Hello.
I'm trying to populate a Word document from an Access table. The word
document has a table and i've added bookmarks to all the cells.
The problem is that when i try to put data on that table 2 weird things
happen. The first is that alltough i change the bookmark, the data is always
written on the first bookmark. The second is that it can't find the bookmark.
Can anyone help me?
The code i'm using is the following:

Dim objWord As Object
Dim objMergeDoc As Object
Dim rs As DAO.Recordset

On Error Resume Next
Set objWord = GetObject("Word.application")

If Err.Number <> 0 Then
Set objWord = CreateObject("word.application")
End If

Err.Clear
Application.FollowHyperlink "\\faial\Ddr\vol1\BD_Valorizacao\NI.rtf"

objWord.Visible = True
objWord.Activate

Set rs = CurrentDb.OpenRecordset("PAs_NotaInterna")
rs.MoveFirst

Book_mark = 1

Do
PA = rs!PA

bkMrk = "PA" & Book_mark
objWord.Bookmarks(bkMrk).Select
objWord.Selection.text = PA
objWord.Refresh
rs.MoveNext
Book_mark = Book_mark + 1
Loop While Not rs.EOF
 

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