Editing Headers/Footers using C# and keeping the same format

A

agraashish

Hi All,
I am trying to automatically update several word documents(using VS2008 and
C#) which are in 20003/2007 format.I want to update some specific fields of
the HEADERS and FOOTERS.I tried the following code but after the Header is
updated its settings change,so is there a way using which I can update the
documents keeping the same settings of Header?

Code Sample:

foreach (Microsoft.Office.Interop.Word.Section section in doc.Sections)
{

section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text =
section.Headers
[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text.Replace("some value
read from header", "new value of field");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top