S
S
Sergey2020-04-21 19:21:47
C++ / C#
Sergey, 2020-04-21 19:21:47

How to change the text of a bookmark in a Word document without deleting it?

In this example, the bookmark is removed, replaced with text. Tell me how to replace the text of the bookmark without deleting it?

string fileName = "Имя_файла.docx";
wordApp = new Word.Application();
document = wordApp.Documents.Open(fileName);
Word.Bookmarks bookmarks = document.Bookmarks;

bookmarks["Дата"].Range.Text = DateTime.Today.ToShortDateString();
bookmarks["Номер"].Range.Text = "12345";

document.Close();
document = null;
wordApp.Quit();
wordApp = null;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question