none
Changing "Move Object with Text" property on a line drawn in programmatically. RRS feed

  • Question

  • I've been trying to figure this out on my own, but I'm getting stuck.

    I'm drawing a line on a document, and want the object to NOT move if text is added above the anchor.  Everything I've tried to this point locks the Anchor in place, but the object itself moves.

    Here is the code I'm using to add the line.

     Dim MyRange As Range
                MyRange = Globals.ThisDocument.Range.GoTo(What:=WdGoToItem.wdGoToPage, Which:=WdGoToDirection.wdGoToAbsolute, Count:=2)
                Dim ExtraGatemark As Shape = Globals.ThisDocument.Shapes.AddLine(568, 99, 604, 99, Anchor:=MyRange)
                ExtraGatemark.Line.ForeColor.RGB = RGB(0, 0, 0)
                ExtraGatemark.Line.Weight = 1

    Essentially, I'm trying to figure out how to check or uncheck the "Move object with text", under options on the Position tab of the Layout window, with code.

    Thursday, January 3, 2013 7:50 PM

Answers

  • Hi Rob

    Try something like the following. You may want to take a look at all the options available in the Enumeration and compare them to what's available in the dialog box for Position (Advanced):
     ExtraGatemark .RelativeVerticalPosition = Word.wdRelativeVerticalPosition.wdRelativeVerticalPositionPage


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, January 4, 2013 9:27 AM
    Moderator

All replies

  • Hi Rob

    Try something like the following. You may want to take a look at all the options available in the Enumeration and compare them to what's available in the dialog box for Position (Advanced):
     ExtraGatemark .RelativeVerticalPosition = Word.wdRelativeVerticalPosition.wdRelativeVerticalPositionPage


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, January 4, 2013 9:27 AM
    Moderator
  • Once again, always helpful, Cindy, thanks!

    It worked.

    I never even thought to try RelativeVerticalPosition.  Now that I know, it sort of makes sense, but I was expecting something along the line of ExtraGatemark.line.lock (which doesn't exist) or something to that effect.

    Friday, January 4, 2013 2:22 PM