Search code examples
dynamicfieldadditiondoc

Printing word document with fields in C# with adding field values at run time


I need to print a word document. but every time i print the document i need to add some values at certain positions and then print the document. I think there is option available of adding fields in doc file and giving it the value at run time. I have googled it but haven't find appropriate solution. Is there any such option available ?


Solution

  • using variables and changing their values is the solution for this issue. we can change vales of a variable at run time in c# using following code:

    ActiveDocument.Variables("replace1").Value = "This is a test"