Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    referring to header with vb (OFFICE 2000)

    I am using bookmarks in a word document along with input boxes to fill in various parts of a letter template. I need to use this technique to insert information in the header section. I have book marked the part of the header but cannot navigate to it in VB. Can anyone help me with this?
    Thank You
    Kevin

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: referring to header with vb (OFFICE 2000)

    Header (and footers) are objects in Section objects. So, your code must
    reference the section first:

    oWord.Section(1).Headers(7).Range.Text etc... 7=wdHeaderFooterPrimary

    If you don't know the section you'll probably have to 'for each' your way
    through all sections until you find some text in the section or the section's
    header that lets you know you're in the right place.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

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

    Re: referring to header with vb (OFFICE 2000)

    Actually it can be done more simply than this - as long as you are addressing the bookmark as a member of the document's bookmarks collection, you don't need to locate the section nor select the bookmark, in order to assign text to it:

    ActiveDocument.Bookmarks("bmkInHeader").Range.Text = "The text you want to insert"

    Gary

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: referring to header with vb (OFFICE 2000)

    Gary,
    Thank You VERY much! I spent 3 days in agony trying to get this to work. Thanks again works great.
    Kevin
    Kevin

Posting Permissions

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