以下是引用办公之星在2004-10-11 17:33:00的发言:
谢谢,测试成功。
是需要每页粘贴一下,但格式只需要设定一次。
请予指导。
错了,应该在页眉中插入文本框,而不是在页面中.
GxWyiKoR.zip
(11.57 KB, 下载次数: 194)
以下代码供参考:
Sub SetMyHeaders()
Dim MyText As Shape, PW As Single, PH As Single, PT As Single, PR As Single, PB As Single
Dim i As Section
On Error Resume Next
Application.ScreenUpdating = False
For Each i In Me.Sections
If i.PageSetup.Orientation = wdOrientLandscape Then
With i.PageSetup
PW = .PageWidth
PH = .PageHeight
PT = .TopMargin
PB = .BottomMargin
PR = .RightMargin
End With
Me.Range(i.Range.Start, i.Range.Start).Select
Application.Run "ViewHeader"
Selection.HeaderFooter.LinkToPrevious = False
Set MyText = i.Headers(wdHeaderFooterPrimary).Shapes.AddTextbox(msoTextOrientationHorizontal, PW - PR, PT, PR * 2 / 3, PH - PT - PB)
With MyText
.Line.Visible = msoFalse
.TextFrame.TextRange.Select
With Selection
.Font.Name = "华文细黑"
.Font.Size = 12
.Font.Bold = True
NormalTemplate.AutoTextEntries("第 X 页 共 Y 页").Insert Where:=Selection. _
Range, RichText:=True
.Orientation = wdTextOrientationVerticalFarEast
.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
End With
End If
Next
Application.ScreenUpdating = True
End Sub
请在运行前保存备份.这二天感觉WORD有些怪怪的,说不上来,又没有染毒,就是不对劲.
你试试看,有问题再说. |