Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Auto: trouble with .GoTo a Bookmark in Word
Message
From
15/04/2008 13:18:40
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Word Auto: trouble with .GoTo a Bookmark in Word
Miscellaneous
Thread ID:
01310785
Message ID:
01310785
Views:
57
Hi all,

I am working away on a Word wrapper class for Word automation. I am having trouble with a wrapper function that tests and moves the insertion point to a bookmark (title GoToBookmark). It is failing on the actual Word command to .GoTo() in a range. I have tried changing the parameter order and have it in the order that the help file says but it fails saying "Bookmark not found". If I check loDocRange.Bookmarks.Count below, it returns 4 (the correct number). Any ideas?
WITH THIS

* (some set up code before this - including getting actve doc)

* next, check that the bookmark exists in the bookmarks collection

STORE loDocument.Bookmarks.Exists(tcBookmarkName) TO llBookmarkFound

* [NOTE: this passes, the bookmark exists]

* if bookmark not found, set errornum and return
IF NOT llBookmarkFound
   STORE -32 TO .inErrorNum
   RETURN .F.
ENDIF

* otherwise, we should be able to go to it but wrap in error trap anyhow

* set the range we want to "Go To" in
loDocRange = .ioActivedocument.Range()

TRY
   * [NOTE: next line fails and goes to the "CATCH".  Outside of the 
   * TRY/CATCH, it returns "Bookmark not found"

   loDocRange.GoTo(wdGoToBookmark,wdGoToFirst,1,tcBookmarkName)
   STORE .T. TO llReturn

CATCH
   STORE -33 TO .inErrorNum
   STORE .F. TO llReturn
ENDTRY

ENDWITH && for WITH THIS

RETURN llReturn
Next
Reply
Map
View

Click here to load this message in the networking platform