SoFunction
Updated on 2025-03-08

Using C# to implement the method of inserting header and footer in word

Operations for Word are a function that many programs have. This article uses examples to show the method of using C# to insert headers and footers in word for reference. The specific methods are as follows:

1. Method of inserting the footer:

public void InsertFooter(string footer) 
{ 
  if ( ==  || 
     == ) 
  { 
     = ; 
  } 
 
   = ; 
   = false; 
   = ; 
  (footer); 
 
  //Bounce out of header footer settings   = ; 
 
} 

2. Method on msdn:

foreach ( wordSection in ) 
{ 
     footerRange = [].Range; 
     = ; 
     = 20; 
     = "Footer Footer"; 
} 

foreach ( section in ) 
{ 
     headerRange = [].Range; 
    (headerRange, ); 
     = ; 
} 

I hope that this example can help you in C# programming.