Solved

MS Word - Remove All hyperlinks - VBA

Posted on 2009-07-06
2
663 Views
Last Modified: 2013-11-10
Hello,

I have a word document that has been created by copying and pasting various webpages.  The problem is that it is littered with hyperlinks that are causing problems in another process.  Is there a way to 'remove all hyperlinks' in a Word document.  Currently I can only see this being possible by manually edit each hyperlink and removing or pressing the remove hyperlink button.

If this is not possible with native features, can somone help with some simple VBA that would do this.  I created some VBA in Excel some time ago to do this - but don't have this anymore and also it had a different object model - not done any VBA in MS Word. I'm guessing it should be very simple.

Raheel
0
Comment
Question by:hennanra3
2 Comments
 
LVL 12

Accepted Solution

by:
geneus earned 500 total points
ID: 24783845
This macro will remove the hyperlinks from all text in the document.
Sub RemoveHyperlinks()
 

Dim y As Long

With ActiveDocument.Hyperlinks

  For y = 1 To .Count

    .Item(1).Delete

  Next y

End With

MsgBox "Completed!"
 

End Sub

Open in new window

0
 

Author Closing Comment

by:hennanra3
ID: 31600090
Wow - that was fantastic and too easy!  Many thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now