Automation: Access to Word_ BookMark does not work in the word table

wlgzhang

Registered User.
Local time
Today, 05:33
Joined
Aug 16, 2004
Messages
19
Hi All,
I set up a word template and have inserted some bookmarks into a table in the template. I try to pull some data form access to this word template.
However, I get a runtime error: You entered multiple destinations for a page, line, footnode, endnote or document. I had done some programs successfuly to insert data into word document (no table) with same fashion, but I can not use the same method to do same thing in a word table.
I am stuck here, could anybody help!

the following are some of my code: :confused:

Sub ProduceSheetBody(wordApp As Word.Application, DesiredSubject As String, SpecifiedSession As String)
Dim ExamInfoRst As Recordset
Dim ExamInfoStr As String

ExamInfoStr = GetExamMarkingInfo(DesiredSubject, SpecifiedSession)

Set ExamInfoRst = CurrentDb.OpenRecordset(ExamInfoStr)

' MsgBox "Get Exam Marking App Info: " & CStr(ExamInfoRst!FirstName) & " " & CStr(ExamInfoRst!LastName) _
& " " & CStr(ExamInfoRst!ExamCode)

With wordApp.Selection
For Num = 1 To 20
If Not ExamInfoRst.EOF Then
.Goto what:=wdGoToBookmark, Name:="ApplicantName" & Num
.TypeText ExamInfoRst!FirstName & " " & ExamInfoRst!LastName
.Goto what:=wdGoToBookmark, Name:="Code" & Num
.TypeText ExamInfoRst!ExamCode
ExamInfoRst.MoveNext
If Not ExamInfoRst.EOF Then
' MsgBox "Get Exam Marking App Info: " & CStr(ExamInfoRst!FirstName) & " " & CStr(ExamInfoRst!LastName) _
& " " & CStr(ExamInfoRst!ExamCode)
End If
Else
.Goto what:=wdGoToBookmark, Name:="ApplicantName" & Num
.TypeBackspace
.Goto what:=wdGoToBookmark, Name:="Code" & Num
.TypeBackspace
End If
MsgBox "in the loop " & CStr(Num)
Next Num

End With

ExamInfoRst.close
Set ExamInfoRst = Nothing

End Sub

In Loop 2, I got this Error message:You entered multiple destinations for a page, line, footnode, endnote or document.

And tha following is a imcompleted out put to the word template (I highlighted the 2 bookMarks )
Examiner: Mullan Subject: Administrative Law

Applicants’ Name Code Pass Fail Mark*

wafik Abadir Adm02

ApplicantNam2 Code2
ApplicantName3 Code3
ApplicantName4 Code4

......

ApplicantName19 Code19
ApplicantName20 Code20

Note:when I paste the table, it's borders are dispeared.
any help is appreciated.
Wei Zhang
 

Users who are viewing this thread

Back
Top Bottom