Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Location
    Barbados, West Indies
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Go to a bookmark in the header

    Hi,

    Word 97SR2

    I'm writing a simple letter template with a UserForm which takes text from the user, e.g. the address, assigns it to a variable, jumps to a bookmark named "address" and does a

    Selection.TypeText (address)

    My problem is that my bookmark is in the Header, and Word cannot find the bookmark there when I do this:

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

    Is there a workaround, or have I been very naive (I am a novice at VBA)?

    TIA,

    Phil Barker

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Go to a bookmark in the header

    Hi Phil,

    You should simply be able to do something like:

    ActiveDocument.Bookmarks("address").Range.Text = strAddress

    This avoids the problem of needing to go to the header etc. plus it will run faster.

    Selection.GoTo will only find things that are in the document's main Story, and not things that are in for example Headers and Footers.

    Gary

  3. #3
    New Lounger
    Join Date
    Jan 2001
    Location
    Barbados, West Indies
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to a bookmark in the header

    Thanks Gary, I'll try it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •