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
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