Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Jan 27, 2023 3:35 pm

Hello!

I've would like to know if its possibly to programmatically using c# and spiredoc to find the specific "field codes" in word and update them with some custom data value without the specific formula. If its possible please for the sample code.

Thank you in advance!

friderik
 
Posts: 2
Joined: Fri Jan 27, 2023 3:27 pm

Sat Jan 28, 2023 8:43 am

Hi,

Thanks for your inquiry.
According to my comprehension, in your photo, “updateMark11” is a bookmark, you want to update some fields like bookmarks with your custom data, you can see the following code for reference.
Code: Select all
            Document doc = new Document();
            doc.LoadFromFile("sample.docx");

            BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(doc);
            bookmarkNavigator.MoveToBookmark("updateMark11");

            bookmarkNavigator.ReplaceBookmarkContent("1000", false);

            doc.IsUpdateFields= true;
            doc.SaveToFile("sample-output.docx", FileFormat.Docx);


If the code does not meet your requirement, please provide us with your input document and expected result document, you can send them to us via email ([email protected]) or attach them here. Thanks for your assistance.

Sincerely,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Tue Jan 31, 2023 1:28 pm

Hello!

Thanks for the reply and for the info. I'd tested and it works fine.

Thank you!

friderik
 
Posts: 2
Joined: Fri Jan 27, 2023 3:27 pm

Wed Feb 01, 2023 1:33 am

Hi,

Thanks for your feedback.
Glad to know that the code works for you! If you have any questions related to our products, just feel free to contact us.

Sincerely,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.Doc