This project has moved. For the latest updates, please go here.

Simple Example for editing Word

Jan 3, 2015 at 10:00 AM
Hi,

I'm new to NetOffice, and I wish to know if is possible to simply open an exisiting Word.doc document, find some specific text within MS Word "TextFormFields", and just replace their content, and save the document?

I couldn't see any in the tutorials, etc...

Thanks for your help and time.

Regards,

Alain
Coordinator
Jan 3, 2015 at 11:39 AM
You find a lot of examples in the word example folder and online:

http://netoffice.codeplex.com/wikipage?title=Word_Examples_EN

this topic shows you more about replace form fields:

http://stackoverflow.com/questions/18533198/filling-fields-in-word-using-c-sharp-and-microsoft-word-interop
(dont worry about ms-interop, the syntax in NetOffice is always pretty the same)

*Sebastian
Jan 4, 2015 at 11:59 AM
Hi Sebastian,

Thank you so much for your help.

The library is excellent. Keep up the good work!!

Regards,

Alain

Sent from Windows Mail

Feb 15, 2015 at 9:52 AM
Hi Sebastian,

While the method that you explain on those samples does provide the means to find the field and replace it for a text.

See my code below:

switch (field.Name)





{



case "ProjectName01":

field.Range.Text = NewValue[0];

break;

This approach replaces the entire field all together for the text. I wish to simply find the field, and replace the content only.

Like the following sample:

Word field.Name = Client01
Word field.Text = Client Name

After the code runs, should be:

Word field.Name = Client01
Word field.Text = John Matthews

I cannot seem to find the property or attribute of the field, to do the above.

Any ideas?

Regards,

Alain