Remove Hyperlinks from Word using C#

This article describes how to remove hyperlinks from Word using C#. You will get details to set up the development environment, step-by-step instructions, and sample code showing how to remove links from Word document using C#. You can also enhance the given sample code to create a custom output document.

  1. Set up the IDE to use Aspose.Words for .NET to remove hyperlinks
  2. Load the source Word file that contains hyperlinks into the Document object
  3. Find all the hyperlinks in the document, skipping those in the table of contents if required
  4. Store the text displayed by each hyperlink
  5. Remove the hyperlinks and keep the hyperlink text as it is
  6. Remove the blue color, underline, and hyperlink style from that text
  7. Clear the hyperlink look from any other text that still uses it
  8. Save the updated Word file and display the number of removed hyperlinks

These steps describe how to remove all hyperlinks in Word using C#. Load the source Word file, find all the hyperlinks in the document except those in the table of contents, and store the text used by each hyperlink. Remove all hyperlinks while keeping the link text, and remove the blue color, underline, and hyperlink style before saving the output Word file.

This code demonstrates how to remove all hyperlinks in Word at once using C#. You can filter hyperlinks by destination address to remove only external web links or links to a specific domain. There is also an option to clear the links attached to images and shapes because the sample code handles only text hyperlinks.

This article teaches the process of searching for and removing hyperlinks while keeping the text in normal format. To work with document revisions and accept all the changes in a Word file, refer to the article Accept all changes in Word using C#.

 English