自動テキスト アイテムをヘッダーに挿入しようとしています。次に、セクションの最初のページでもある偶数ページにある場合にのみ、自動テキスト アイテムを移動します。
私のコードは自動テキストを挿入しますが、それを移動する方法がわかりません。
Sub InsertHeader()
Dim oShape As Shape
Dim PageNumber As Integer
Dim oSection As Section
Dim oHeader As HeaderFooter
For Each oSection In ActiveDocument.Sections
If oSection.Index > 1 Then
For Each oHeader In oSection.Headers
oHeader.Range.Select
PageNumber = Selection.Information(wdActiveEndPageNumber)
If oHeader.Exists Then
Select Case oHeader.Index
Case Is = wdHeaderFooterFirstPage
If PageNumber Mod 2 = 0 Then
ActiveDocument.AttachedTemplate.AutoTextEntries("HeaderFirst"). _
Insert Where:=Selection.Range
End If
End Select
End If
Next oHeader
End If
Next oSection
End Sub
入れてみInsert Where:=Selection.Range Left:=CentimetersToPoints(2.26)
ましたが、VBA エディターはそれを受け入れません。また、ヘッダー内のすべての図形を見つけて移動しようとしました:
ActiveDocument.AttachedTemplate.AutoTextEntries("HeaderFirst"). _
Insert Where:=Selection.Range
For Each oShape In oHeader.Shapes
oShape.Left = CentimetersToPoints(2.26)
''oHeader.Range.Shape(1).Left = CentimetersToPoints(1)
Next oShape
しかし、それは私が挿入した形状だけでなく、ドキュメント内のすべてのヘッダーの形状を移動します。