0

I’m building an application that would look for merge fields in a word document and replace them with input from the users. However I cannot seem to find how to replace the header section, on each page with users input.

it should just replace the merge fields «ClientName» & «Date» on each page with the correct information. Im using merge fields already to replace fields threw out the word document already

Example

// This code works in the body of the word document
foreach (Microsoft.Office.Interop.Word.Field field in document.Fields)

else if (field.Code.Text.Contains("Zip"))
                    {

                        field.Select();
                        string zip = czipcodebox.Text;
                        application.Selection.TypeText(zip);

                    }

However when ever i try to replace the the header section its skips it

Im trying to replace the header inside the document not the document name

  • 1
    Check out the OpenXml SDK. It is very useful for this sort of thing. – emsimpson92 Jun 18 '18 at 17:43
  • 1
    Possible duplicate of [Replace Field in Header&Footer in Word Using Interop](https://stackoverflow.com/questions/17714642/replace-field-in-headerfooter-in-word-using-interop) – emsimpson92 Jun 18 '18 at 17:47

0 Answers0