怎样添加页脚
向大侠求助:用VB调试word文档,文字修改存盘成功了。现在不懂页脚怎样写程序,问度娘终没正果。Public Sub Ca涵()
Set WordApp = CreateObject("Word.Application")
' WordApp.Visible = True
Set Word = WordApp.Documents.Open(App.Path & "\存放夹\分部_涵洞.doc")
Word.Tables(1).Cell(2, 1) = Str项目名
Word.Tables(1).Cell(4, 1) = Str分部名 & "分部工程验收报告"
Word.Tables(1).Cell(5, 1) = Str简 & "[" & Year年 & "]分验" & Num分部序号 & "号"
Word.Tables(1).Cell(10, 2) = Str单项名
Word.Tables(1).Cell(11, 2) = Str单位名
Word.Tables(1).Cell(12, 2) = Str分部名
Word.Tables(1).Cell(14, 1) = Str分部名 & "分部工程验收组"
Word.Tables(1).Cell(15, 1) = Ymd年月日
Dim r As Range
'给文档的第一节页脚添加页码
Set r = Word.Sections(1).Footers.Range '运行显示“实时错误'438'对象不支持该属性或方法”
With r
.InsertAfter "第"
.Font.Size = 20
.Collapse Direction:=wdCollapseEnd
'插入页码域
.Fields.Add Range:=r, Type:=wdFieldEmpty, Text:= _
"PAGE \* Arabic ", PreserveFormatting:=True
.Expand unit:=wdWord
.InsertAfter "页 "
.InsertAfter "共"
.Collapse Direction:=wdCollapseEnd
'插入页数域
.Fields.Add Range:=r, Type:=wdFieldEmpty, Text:= _
"NUMPAGES \* Arabic ", PreserveFormatting:=True
.Expand unit:=wdWord
.InsertAfter "页"
.InsertAfter "'" & Str分部名 & "_" & Str简 & " "
.ParagraphFormat.Alignment = wdAlignParagraphRight
End With
'隐藏页眉的横线
Word.Sections(1).Headers(wdHeaderFooterPrimary).Range.Borders(wdBorderBottom).Visible = False
Word.SaveAs (Print打印夹 & "\分部工程\涵分部\涵洞(" & "_" & Str分部名 & "_" & Str简 & ").doc") '另存
Word.Close
WordApp.Quit
Set Word = Nothing
Set WordApp = Nothing
End Sub