Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Locking a Shape in Headers (Word 2000)

    I have a document that has three header types: first page, odd, and even.

    I have a macro that steps through each of the three header panes and calls another sub to draw. The function that does the drawing looks like:

    <pre>Private Sub DrawvLine(x, y, ystop)
    If ystop < 0 Then pad = 5 Else pad = -5
    Set myHeader = Selection.HeaderFooter
    Set myLine = myHeader.Shapes.AddLine(x, y + pad, x, y - ystop)
    With myLine.Line
    .Weight = 1
    '.DashStyle = msoLineDash
    .Style = msoLineSingle
    .ForeColor.RGB = RGB(128, 128, 128)
    .BackColor.RGB = RGB(255, 255, 255)
    End With
    End Sub
    </pre>


    What I want to do is to LOCK the shape relative to the page boundaries -- rather than the default which has the shape relative to paragraph and has Move with paragraph checked.

    What I've tried is the following loop:

    <pre>Sub LockHeaderShapes()
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    Stop
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.HeaderFooter.Shapes.SelectAll
    With Selection.ShapeRange
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
    End With
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    End Sub
    </pre>

    The interesting thing is this. It does what you'd expect on the first page header. But on ODD and EVEN it changes the placement of the shape entirely.

    I also tried putting

    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage

    in the with loop at the time of shape creation, it changes the position.

    What am I missing? Any clues as to how to do this?

  2. #2
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Quakertown, PA, Pennsylvania, USA
    Posts
    517
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Locking a Shape in Headers (Word 2000)

    Hate to sound lame if the answer isn't really what you're looking for, but have you considered doing it with autotext instead of actually drawing it each time in your code? If you use the autotext, you should be able to create it exactly as you want it to appear in each one, perhaps creating 3 autotext entries (one first, one odd, one even), and then inserting them instead of drawing it each time.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Locking a Shape in Headers (Word 2000)

    Thanks for the reply.

    Autotext would not work in this context.

    The drawing is based on an equation drawn from page size and margin settings. It could vary each time the macro is run.

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

    Re: Locking a Shape in Headers (Word 2000)

    Guy,

    I did something similar to this at work last week - don't have the code available right now but believe it was necessary to specify via code that the shape was locked, as well as the Left and Top properties for its relative horizontal and vertical position.

    Try adding statements along the lines of:

    .LockAnchor = True
    .Left = InchesToPoints(1.25)
    .Top = InchesToPoints(0.75)

    into the LockHeaderShapes sub (after the With Selection.ShapeRange bit where you indicate the Horizontal and Vertical relative to page setting).

    One way to expose the code equivalents to all of the options available in Format Autoshape is to record a macro where you access this dialog - probably don't even need to change any settings in it i.e. just click OK.

    Hope this helps,
    Gary

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Locking a Shape in Headers (Word 2000)

    Thanks Gary.

    That set me on the right track.

    Basically, AFTER creating the line with the code for AddLine, I did

    <pre>myline.Select
    Selection.ShapeRange.RelativeHorizontalPosition = _
    wdRelativeHorizontalPositionPage
    Selection.ShapeRange.RelativeVerticalPosition = _
    wdRelativeVerticalPositionPage
    Selection.ShapeRange.Left = x
    Selection.ShapeRange.Top = y
    </pre>


    Which seems to have done the trick.

Posting Permissions

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