首页 > 解决方案 > 主要和偶数标题中的 MS Word 文本框(第 2 部分)

问题描述

我无法让我的第二个文本框显示在偶数页标题中。当我运行以下代码时,两个文本框都显示在主标题中。请注意,标题中存在现有文本,我将单独留下。

''' Dim Box As Shape Dim Box2 As Shape Dim ndx As Integer

With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
    Set Box = .Shapes.AddTextbox( _
        Orientation:=msoTextOrientationHorizontal, _
        Left:=InchesToPoints(1), Top:=InchesToPoints(0.5), Width:=InchesToPoints(4.8), Height:=InchesToPoints(0.37))
 End With

 With Box.TextFrame.TextRange
     .Bold = True
     .Font.Size = 8
     .Text = "This is a sample policy from another school district. Contents do not necessarily reflect official " & _
         vbCrLf & "MSBA policy, represent MSBA legal advice or service, and are not intended for exact replication."
End With

If ActiveDocument.ActiveWindow.Panes(1).pages.Count > 1 Then

    With ActiveDocument.Sections(1).Headers(wdHeaderFooterEvenPages)

        .Range.InsertAfter " "
        Set Box2 = .Shapes.AddTextbox( _
            Orientation:=msoTextOrientationHorizontal, _
            Left:=InchesToPoints(3), Top:=InchesToPoints(0.5), Width:=InchesToPoints(4.8), Height:=InchesToPoints(0.37))
    End With

     With Box.TextFrame.TextRange
         .Bold = True
         .Font.Size = 8
         .Text = "This is a sample policy from another school district. Contents do not necessarily reflect official " & _
             vbCrLf & "MSBA policy, represent MSBA legal advice or service, and are not intended for exact replication."
    End With

End If

'''

我很感激帮助。苏珊

标签: headertextboxword

解决方案


推荐阅读