Replace Field in Header&Footer in Word Using Interop
问题 How to replace a "FIELD" in the header/footer? Ex: Word doc file with File Name & Date. in place of file path - [FilePath] instead C://Documents/Location/Filename.doc ,[Date] instead 18/07/2013. I can replace any text with range. foreach (Microsoft.Office.Interop.Word.Section section in wordDocument.Sections) { section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text.Replace(sourceDocPath, "[File Path]"); section.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text