Word中的宏代码(5):在页脚中添加文档名称和保存路径
软件世界
目的
在页脚中添加文档名称和保存路径,方便查找。
宏代码
Sub bclj()
ActiveWindow.ActivePane.View.SeekView=wdSeekCurrent
PageFooter
Selection.ParagraphFormat.Alignment = wdAlignParagraph
Right
Selection.Fields.Add Ran
ge:=Selection.Range,Type:=wd
FieldEmpty, Text:="FILENAME \p ", PreserveFormatt
ing:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMain
Document
End Sub
进阶
如果将第二行代码最后的“Footer”换成“Header”,则运行该宏后,文档名称和保存路径将添加到“页眉”中;如果将第三行代码最后的“Right”换成,“Center”或“Left”,则运行该宏后,相应的内容会“居中”或“左对齐”排列。