Open Word File and GoTo bookmark

  • The following code executes without error, and opens the word file. Problem is it doesn't actually go to the bookmarked location specified, but stays on the initial view at beginning of document. I don't do much with Word, and am a little clueless here. Can someone show me the error of my ways?



    I also tried (instead of the wrdDoc.Goto statement):

    Code
    With wrdDoc
    .Selection.GoTo What:=wdGoToBookmark, Name:="Census"
    End With
  • Re: Open Word File and GoTo bookmark


    You were very close the following code will work for you be sure you have Microsoft Word Library referenced. Hope this helps!

  • Re: Open Word File and GoTo bookmark


    This is definitely an improvement, but I should have explained my full goal a little better - I would like to show the bookmark location at the top of the screen, like the effect of manually performing a GoTo action. While your revision does get the cursor to the bookmark, it doesn't shift it up the screen. It's current orientation at screen bottom when file opens is likely to confuse my users. Is there a way to get the screen shift as well? Thanks so much, I really appreciate the help!

  • Re: Open Word File and GoTo bookmark


    Not an expert on Word VBA by any means but the following seemed to work for me:

    Code
    Selection.GoTo What:=wdGoToBookmark, Name:="Test"


    Although normally I would shy away from using Selection/Select, since in this case you actually want the cursor to change positions then I think that is what is required.

    Since I believe there can only be one active Selection I don't think you need to qualify it with a document (in fact I seemed to get a run-time error when I tried).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!