我知道有类似的代码:
With ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary).Range
.Text = myFooterValue1
.ParagraphFormat.Alignment = wdAlignPageNumberLeft
.Font.Size = 10 'size 10 font
End With
但我想添加,左(公司名称)右(日期)和中间页码。
答案 0 :(得分:0)
您可以使用TabStops。
你需要计算页面的宽度(减去边距),添加一个中心和右边的TabStop,并用标签分隔你的值。
Sub insertFooters()
Dim pageWidth As Double, section As section
For Each section In ActiveDocument.Sections
With section.PageSetup
pageWidth = (.pageWidth) - .LeftMargin - .RightMargin
End With
With section.Footers(wdHeaderFooterPrimary).Range
.Text = "Left" & vbTab & "Center" & vbTab & "Right"
With .ParagraphFormat
.TabStops.ClearAll
.TabStops.Add pageWidth / 2, Alignment:=WdAlignmentTabAlignment.wdCenter
.TabStops.Add pageWidth, Alignment:=WdAlignmentTabAlignment.wdRight
End With
.Font.Size = 10
End With
Next
End Sub