Answer the question
In order to leave comments, you need to log in
How to change headers and footers in docx file via c# - WindowsForms?
In general, the problem is that I need to insert variables into the headers and replace them with my own value through the textbox, but since these variables are in the headers, the program does not see them and does not change them, maybe someone has encountered this problem, help.
Answer the question
In order to leave comments, you need to log in
I see the following options:
Using the Word application - record a macro that it does in VBA (enable macro recording, manually follow the steps, then look at the code in VBA). Then translate to C#
Using the OpenOffice XML SDK - parse and replace in the file as needed.
Also don't forget that docx is zipped XML that can be parsed and transformed
Headers and footers are accessed through Document.Sections
Example:
www.programmersforum.ru/showthread.php?t=64739
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question