K
Keith G Hicks
word 03
access 2k
vba automation from access
I'm trying to put the # of pages in a bookmark on page one after the entire
doc has been filled in. I set the values of several dozen bookmarks and once
I'm at the end I need to go back to a bookmark on page one and set it's
value but I keep getting "bookmark does not exist" types of errors.
Here's what I have:
Global objWord As Word.Application
Global docWord As Word.Document
'word is opened in a separate function
Set docWord = objWord.Documents.Add(Template:=sWordFormsPath &
"myTemplate.dot")
with docWord
'the next 4 lines all work fine
.Bookmarks("NumPages").Range.Text = 0
.Bookmarks("OwnOpName9").Range.Text = Nz(rs!OwnOpName, "")
.Bookmarks("EntityName9").Range.Text = Nz(rs!CustName, "")
.Repaginate
'the next line crashes
'.Bookmarks("NumPages").Range.Text =
Str(docWord.ComputeStatistics(wdStatisticPages))
'the next line crashes
'.FormFields.Item("NumPages").Result =
Str(docWord.ComputeStatistics(wdStatisticPages))
'the next line crashes
objWord.Selection.GoTo what:=wdGoToBookmark, Name:="NumPages"
'.GoTo what:=wdGoToSection, Name:=3
'.Bookmarks("NumPages").Range.Text =
Str(docWord.ComputeStatistics(wdStatisticPages))
end with
The bookmark "numpages" does exist and when I set it initially to 0 it works
fine.
Thanks,
Keith
access 2k
vba automation from access
I'm trying to put the # of pages in a bookmark on page one after the entire
doc has been filled in. I set the values of several dozen bookmarks and once
I'm at the end I need to go back to a bookmark on page one and set it's
value but I keep getting "bookmark does not exist" types of errors.
Here's what I have:
Global objWord As Word.Application
Global docWord As Word.Document
'word is opened in a separate function
Set docWord = objWord.Documents.Add(Template:=sWordFormsPath &
"myTemplate.dot")
with docWord
'the next 4 lines all work fine
.Bookmarks("NumPages").Range.Text = 0
.Bookmarks("OwnOpName9").Range.Text = Nz(rs!OwnOpName, "")
.Bookmarks("EntityName9").Range.Text = Nz(rs!CustName, "")
.Repaginate
'the next line crashes
'.Bookmarks("NumPages").Range.Text =
Str(docWord.ComputeStatistics(wdStatisticPages))
'the next line crashes
'.FormFields.Item("NumPages").Result =
Str(docWord.ComputeStatistics(wdStatisticPages))
'the next line crashes
objWord.Selection.GoTo what:=wdGoToBookmark, Name:="NumPages"
'.GoTo what:=wdGoToSection, Name:=3
'.Bookmarks("NumPages").Range.Text =
Str(docWord.ComputeStatistics(wdStatisticPages))
end with
The bookmark "numpages" does exist and when I set it initially to 0 it works
fine.
Thanks,
Keith