使用 VBA 代码/宏更改 Word 文档中的页脚
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13645611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change the footer in a word document with VBA code / Macro
提问by Mana
How can I change the footer information in a word document with VBA?
如何使用 VBA 更改 Word 文档中的页脚信息?
When the document is loaded, the VBA code will get the necessary info from a database, and I want to attach that info to the footer.
加载文档后,VBA 代码将从数据库中获取必要的信息,我想将该信息附加到页脚。
I got the fetching the info from the DB down, but attaching it to the footer is another story.
我从数据库中获取信息,但将其附加到页脚是另一回事。
Any simple related examples are appreciated.
任何简单的相关示例表示赞赏。
回答by Zaider
This will create a header and footer on every page.
这将在每个页面上创建页眉和页脚。
With ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text = "Header goes here"
.Footers(wdHeaderFooterPrimary).Range.Text = "Footer goes here"
End With
You can find more information on how to use headers and footers with vba here: http://msdn.microsoft.com/en-us/library/office/aa221968%28v=office.11%29.aspx
您可以在此处找到有关如何在 vba 中使用页眉和页脚的更多信息:http: //msdn.microsoft.com/en-us/library/office/aa221968%28v=office.11%29.aspx