Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 03 APR 2007 02:47:05PM Hank Huizinga wrote:

I'm trying to open a Word document and then goto a specific bookmark. I want to use the Word "goto" function since it positions the bookmark at the top of the page.

Here is the code I am using (borrowed from Bob's). It is just some simple code that counts the number of bookmarks in a document and moves to the last one. It all works except for the GoTo command. If anybody has a suggestion, I would appreciate it.

Subroutine Ole_Word_Example3(null)

equ wdGoToBookmark to -1

oWrd = OleCreateInstance("Word.Application")

OlePutProperty(oWrd,'Visible', 1)

oDocuments = oleGetProperty(oWrd, 'Documents')

oDoc = OleCallMethod(oDocuments, 'OPEN', "O:\Hank\test.doc")

Selection = oleGetProperty(oWrd, "SELECTION")

oMarks = oleGetProperty(oDoc, "Bookmarks")

mcnt = oleGetProperty(oMarks, "Count")

oMark = OleCallMethod(oMarks, "ITEM", mcnt)

bookmarkname = oleGetProperty(oMark, "Name")

x = OleCallMethod(Selection, "GoTo", wdGoToBookmark,,,bookmarkname)

RETURN 1


At 03 APR 2007 05:14PM Bob Carten wrote:

Hi Hank

I'm not sure GoTo is a method for the selection object.

Instead of

x=OleCallMethod(Selection, "GoTo", wdGoToBookmark,,,bookmarkname)

try

x=OleCallMethod(OWrd, "GoTo", wdGoToBookmark,,,bookmarkname)

if that does not work, try using the macro recorder, see what object it uses for the goto.

- Bob


At 04 APR 2007 05:27PM Hank Huizinga wrote:

This is the macro , selection appears to be correct

Selection.GoTo What:=wdGoToBookmark, Name:=test"

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/32707bddf501586e852572b200673048.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1