Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

return to bookmark on page one after all the way to end of doc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith G Hicks - 20 Sep 2007 17:44 GMT
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
Keith G Hicks - 20 Sep 2007 17:53 GMT
Never mind. My bookmarks are in form fields. I just realized that once the
field is filled in in code, the bookmark no longer exists. I took out the
line that first sets it to 0 and all is good.

Keith
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.