
- Controling headers and footers in microsoft word how to#
- Controling headers and footers in microsoft word code#
For Each section As Word.Section In Me.įoreach (Word.
Controling headers and footers in microsoft word code#
This code example uses the active document. The following code example adds a field to show the page number in each header in the document, and then sets the paragraph alignment so that the text aligns to the right of the header.
Controling headers and footers in microsoft word how to#
For Each section As Word.Section In Me.įoreach (Word.Section wordSection in ) Word Tutorial topics: How to insert headers and footers in Word - How to edit headers and footers in Word 2016 - Adding dynamic content to headers and footers in Word - Adding images or logos to. The following code example sets the font of the text to be inserted into the primary footer of each section of the document, and then inserts text into the footer. To use the following code examples, run them from the ThisAddIn class in your project.

Word gives you extensive control over headers and footers. = įoreach (Word.Section section in this.Sections) Typically, headers and footers appear at the top or bottom of every page, perhaps with modifications (such as page numbers that change with every page). The procedures are different for document-level customizations and VSTO Add-ins. Each section of a document contains three headers and footers: wdHeaderFooterPrimary. For Each section As Word.Section In Me.Sectionsĭim headerRange As Word.Range = section.Headers().Range You can add text to headers and footers in your document by using the Headers property and Footers property of the Section. In this lesson, you will learn how to insert built-in and blank headers and footers. Headers and footers generally contain information such as page number, date, and document name. The following code example adds a field to show the page number in each header in the document, and then sets the paragraph alignment so that the text aligns to the right of the header. The header is a section of the document that appears in the top margin, while the footer is a section of the document that appears in the bottom margin. For Each section As Word.Section In Me.Sectionsĭim footerRange As Word.Range = section.Footers().Rangeį = įoreach (Word.Section wordSection in this.Sections) To use the following code examples, run them from the ThisDocument class in your project.

For more information, see Features available by Office application and project type.

The procedures are different for document-level customizations and VSTO Add-ins.Īpplies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word. In this video I show you how to lock and protect the Header and Footer sections in a Microsoft Word document so that no one can edit or remove them in any wa. Each section of a document contains three headers and footers: You can add text to headers and footers in your document by using the Headers property and Footers property of the Section.
