关键是设置测量的位置(
RelativeHorizontalPosition
)然后使用形状的
Left
背景相对于几乎任何东西
wdCharacter
编辑文本时,页面上的水平位置将是静态的;垂直地
wdLine
和
wdParagraph
相当于使用“随文本移动”。
通过为最后一节和形状声明和使用对象,我简化了您发布的代码。
此代码使用
Range.FormattedText
要复制,请将内容从一个标题传输到另一个标题。这比将剪贴板用于它工作的那些情况(在任何两个单词范围之间)更可取。
Dim secLast as Word.Section
Dim shp as Word.Shape
Set secLast = ActiveDocument.Sections.Last
secLast.PageSetup.Orientation = wdOrientLandscape
secLast.PageSetup.DifferentFirstPageHeaderFooter = False
secLast.Headers(wdHeaderFooterPrimary).Range.FormattedText = _
ActiveDocument.Sections(secLast.index - 1).Headers(wdHeaderFooterPrimary).Range.FormattedText
secLast.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
secLast.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
formatHeader wdHeaderFooterPrimary
formatHeader wdHeaderFooterFirstPage
Set shp = secLast.Range.Shapes(1)
shp.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
shp.Left = 33 ' Or you can use, for example CentimetersToPoints(1.4)
shp.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shp.Top = CentimetersToPoints(14)