Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Feb 2001
    Location
    Georgia, USA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting a textbox in a header.

    I am trying to set up a portrait header for a landscaped page in a document. Below is the code I am currently trying to insert a text box for the text:

    On Error GoTo NoLandEvenHeader
    ActiveWindow.ActivePane.View. _
    SeekView = wdSeekEvenPagesHeader
    Set myTextBox = varSection. _
    Headers(wdHeaderFooterEvenPages).Shapes.AddTextbox _
    (wdTextOrientationDownward, _
    InchesToPoints(10), _
    InchesToPoints(0.75), _
    InchesToPoints(0.5), _
    InchesToPoints(6.5))
    myTextBox.Select
    Selection.EndKey Unit:=wdLine, Extend:=wdMove
    NoLandEvenHeader:


    When the SeekView routine is called, if the section has only one page, then even or primary pages will fail with the Runtime Error 5895, "Requested View is Not Available."

    I understand why the view is not available, but the error trapping doesn't catch it so that I can skip that header.

    Of course I'd prefer a routine that would insert the text box for all 3 headers of a section, just in case the landscaped page changes from odd to even because of other pages inserted.

    Thanks,
    mike c.

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Inserting a textbox in a header.

    One way to get around it would be to insert two page breaks into the section before hitting the header view area. When done you can delete them again.

    The other option would be to use ranges instead of selection objects.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Inserting a textbox in a header.

    You might be able to "cheat" using the old WordBasic object. I have this in some code to set the header (not the first page header):

    ActiveWindow.View.Type = wdNormalView
    WordBasic.NormalViewHeaderArea
    With Selection
    'do stuff
    End With
    WordBasic.ClosePane

    You have no control over what you get in this pane, but from my limited testing:

    (1) First page different; no odd/even: opens p2 header;
    (2) Odd/even; no first page different: opens even header;
    (3) Both: opens first page header.

    You can check the header settings for a given section in the PageSetup object

  4. #4
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Pune
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting a textbox in a header.

    Please look at this thread for an elegant solution

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Inserting a textbox in a header.

    I don't know if this applies in this situation, but I've often found that errors on trying to deal with viewing headers/footers can be stopped by adding 'activedocument.' to the front of the 'activewindow.activepane.view ...' lines.

    I don't know why it works but it has done so in the past!
    Beryl M


Posting Permissions

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