I am working on a VBA macro, which I wrote only parts of it myself, for MS-Word that changes the orientation of the page and then copies the header and footer of previous pages to the new page and some other stuff:
Selection.PageSetup.Orientation = wdOrientLandscape
ActiveDocument.Sections.Last.PageSetup.DifferentFirstPageHeaderFooter = False
ActiveDocument.Sections(ActiveDocument.Sections.Last.index - 1).Headers(wdHeaderFooterPrimary).Range.Select
Selection.Copy
ActiveDocument.Sections.Last.Headers(wdHeaderFooterPrimary).Range.Select
Selection.Paste
ActiveDocument.Sections.Last.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
ActiveDocument.Sections.Last.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
formatHeader wdHeaderFooterPrimary
formatHeader wdHeaderFooterFirstPage
There is a text in a TextBox which is anchored to header. What I want to do now is to change its position on the pages with "Landscape" orientation.
How can I change the layout options (see images below)? I haven't been able to find any information.
This is how my document looks like after changing the page orientation to "Landscape":

As you see, the paragraph on the side, in the TextBox is not in the middle. so I want to move it a bit higher. You can also see the anchor in this image.

This is how I did it in Word as a user:


The key is to set where the measurement should be taken from (
RelativeHorizontalPosition) and then use the Shape'sLeftsetting. Relative to pretty much anything exceptwdCharacterthe horizontal position will be static on the page when the text is edited; vertically,wdLineandwdParagraphwould be equivalent to using "Move with text".I've streamlined the code you posted somewhat by declaring and using objects for the last Section and the Shape.
Instead of copying and pasting, this code uses
Range.FormattedTextto copy-transfer the content from one header to another. This is preferable to using the Clipboard for those situations where it works (between any two Word Ranges).