none
Word 2013, RelativeHorizontalPosition does not work as it did in Word 2003 RRS feed

  • Question

  • Hi all,

    I am struggling with a small macro that is supposed to put a textbox in  the margin of a paragraph. This used to work just fine in Word97/2003 but somehow it does not in Word 2013. The text box ends up at the top left of the page. RelativeHorizontalPosition  and RelativeVericallPosition have no influence on the placement. Can't understand why...

    Sub TekstVakInvoegen()

    Application.ScreenUpdating = False Hoogte = CentimetersToPoints(1.27) ' Hoogte van Text Vak in points Breedte = CentimetersToPoints(4.1) ' Breedte van Text Vak in points PlaatsLeft = CentimetersToPoints(0) ' Plaats LEFT van Text Vak in points PlaatsTop = CentimetersToPoints(0) ' Plaats TOP van Text Vak in points Set myDoc = ActiveDocument Set myTextVak = myDoc.Shapes.AddTextbox(msoTextOrientationHorizontal, _ PlaatsLeft, PlaatsTop, _ Breedte, Hoogte, Selection.Paragraphs(1).Range) With myTextVak .RelativeHorizontalPosition = _ wdRelativeHorizontalPositionMargin .RelativeVerticalPosition = _ wdRelativeVerticalPositionParagraph .LockAnchor = True .Fill.BackColor = 0 .Fill.Visible = msoFalse .Fill.Transparency = 0# .Line.BackColor = RGB(255, 255, 255) .Line.Transparency = 0# .Line.Visible = msoFalse .LockAspectRatio = msoFalse .TextFrame.MarginLeft = 0# .TextFrame.MarginRight = 0# .TextFrame.MarginTop = 0# .TextFrame.MarginBottom = 0# .WrapFormat.Type = wdWrapNone .WrapFormat.Side = wdWrapBoth .WrapFormat.DistanceTop = CentimetersToPoints(0) .WrapFormat.DistanceBottom = CentimetersToPoints(0) .WrapFormat.DistanceLeft = CentimetersToPoints(0.32) .WrapFormat.DistanceRight = CentimetersToPoints(0.32) End With myTextVak.Select Selection.WholeStory Selection.Style = ActiveDocument.Styles("Tekst Vak Vet") Application.ScreenUpdating = True Application.ScreenRefresh End Sub


    Tuesday, January 27, 2015 9:02 PM

Answers

  • Hi ddt333,

    Base on my test again, I found that if the value of relative position is less than 1, it will uses the absolute position, you could change its position to relative position with the value less than 1 (e.g. 0), after save and re-check its position, you will find that it still uses absolute position. By default it uses the absolute position, so when we add the new textbox to the document, its position is at left-top of document (left=0, top=0).

    The RelativeHorizontalPostion property is used to specify its relative to type (e.g. page, marging)

    There are LeftRelative and TopRelative properties of shape, so please specify these properties’ value, then change relative to type of shape.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 30, 2015 2:30 AM
    Moderator

All replies

  • Hi ddt333,

    Base on my test in word 2013 and 2010, the result is the same as you.

    Then, I check the labout of textbox, it selects absolute postion. I will do more test to check it.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Thursday, January 29, 2015 7:41 AM
    Moderator
  • Hi ddt333,

    Base on my test again, I found that if the value of relative position is less than 1, it will uses the absolute position, you could change its position to relative position with the value less than 1 (e.g. 0), after save and re-check its position, you will find that it still uses absolute position. By default it uses the absolute position, so when we add the new textbox to the document, its position is at left-top of document (left=0, top=0).

    The RelativeHorizontalPostion property is used to specify its relative to type (e.g. page, marging)

    There are LeftRelative and TopRelative properties of shape, so please specify these properties’ value, then change relative to type of shape.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 30, 2015 2:30 AM
    Moderator