How to break all links in a Word document

Hi,

I want to break all links in a Word document automatically.

Instead of the slow way below:

  1. Open a Word file.
  2. Break all links(see my attachment).
  3. Click save.
  4. Close the file.
  5. Open another file.

Hi Doris,

Thanks for your inquiry. You can convert all Hyperlink fields in a Word document to static texts by using the following code snippet:

Document doc = new Document(MyDir + "in.docx");
// Pass the appropriate parameters to convert all Hyperlink fields encountered in the document (including headers and footers) to static text.
FieldsHelper.ConvertFieldsToStaticText(doc, FieldType.FieldHyperlink);
// Save the document with fields transformed to disk.
doc.Save(MyDir + "Out.docx");

You can find the implementation of “FieldsHelper.ConvertFieldsToStaticText” method in the following page:

https://docs.aspose.com/words/net/updating-and-removing-a-field/

Please let me know if I can be of any further assistance.