简体   繁体   中英

Change the footer in a word document with VBA code / Macro

How can I change the footer information in a word document with VBA?

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM