The operation for word is a lot of the functions of the program, this article is to demonstrate the use of C # Implementation of the method of inserting headers and footers in Word, for your reference, the specific method is as follows:
First, insert the footer method:
public void Insertfooter (string footer) { if (ActiveWindow.ActivePane.View.Type = = Wdviewtype.wdnormalview | | ActiveWindow.ActivePane.View.Type = = Wdviewtype.wdoutlineview) { ActiveWindow.ActivePane.View.Type = Wdviewtype.wdprintview; } ActiveWindow.View.SeekView = Wdseekview.wdseekcurrentpagefooter; This. Application.Selection.HeaderFooter.LinkToPrevious = false; This. Application.Selection.HeaderFooter.Range.ParagraphFormat.Alignment = Wdparagraphalignment.wdalignparagraphcenter ; ActiveWindow.ActivePane.Selection.InsertAfter (footer); Jump out of header footer settings ActiveWindow.View.SeekView = wdseekview.wdseekmaindocument;}
Ii. methods on MSDN:
foreach (Word.section wordsection in this. Application.ActiveDocument.Sections) { Word.Range footerrange = wordsection.footers[ Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]. Range; FooterRange.Font.ColorIndex = Word.WdColorIndex.wdDarkRed; FooterRange.Font.Size =; Footerrange.text = "Footer Footer";} foreach (word.section. Application.ActiveDocument.Sections) { word.range headerrange = section. Headers[word.wdheaderfooterindex.wdheaderfooterprimary]. Range; HEADERRANGE.FIELDS.ADD (Headerrange, Word.WdFieldType.wdFieldPage); HeaderRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;}
I hope the example of this article can help you in C # programming.
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
Use C # to implement a method for inserting header footers in Word
This address: http://www.paobuke.com/develop/c-develop/pbk23632.html
Related Content C # Seven classic sorting algorithm series (UP) C # Add a watermark to a PDF file C # implement file upload and download features example C # DataTable Compute Method Usage Highlights (numeric/string/operator/table Operations)
C # Programming Self-taught data types and variables a C # method of sending data to clipboard and fetching data from clipboard C # custom serialization ISerializable Implementation Method C # The difference analysis between IS and as
Use C # to implement a method for inserting header footers in Word