wlgzhang
10-17-2004, 01:06 PM
Hi All,
I am developing a BDMS by using Access, have been asked to publish data to a word table, I inserted some bookmarks into this table. I try to pull data form access and insert these data onto mapped bookmarks. When I run the code, I get a runtime error: You entered multiple destinations for a page, line, footnode, endnote or document. I do not have much experience with word, and I may not use right methods to do what I needs. I am stuck here, could anybody help!
the following are some of my code:
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 'at the second loop I got the error message
.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 incomplete out put to the word template (red color are bookMarks, blue text are the output data )
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, its borders are disappeared.
Any help is much appreciated.
Wei Zhang
I am developing a BDMS by using Access, have been asked to publish data to a word table, I inserted some bookmarks into this table. I try to pull data form access and insert these data onto mapped bookmarks. When I run the code, I get a runtime error: You entered multiple destinations for a page, line, footnode, endnote or document. I do not have much experience with word, and I may not use right methods to do what I needs. I am stuck here, could anybody help!
the following are some of my code:
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 'at the second loop I got the error message
.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 incomplete out put to the word template (red color are bookMarks, blue text are the output data )
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, its borders are disappeared.
Any help is much appreciated.
Wei Zhang