Mass-remove hyperlinks from Publisher Document (VBA macro)

Joined
Dec 23, 2017
Messages
1
Reaction score
0
I'm using Windows 7 and Publisher 2010.
I copy/pasted multiple scraps together to make a booklet.
I'm trying different methods to remove hyperlinks using VBA macros, but I only get cryptic error messages.
I tried the following code:

Sub DeleteMSHyperlinks()
Dim pgsPage As Page
Dim shpShape As Shape
Dim hprLink As Hyperlink
For Each pgsPage In ActiveDocument.Pages
For Each shpShape In pgsPage.Shapes
If shpShape.HasTextFrame = msoTrue Then
If shpShape.TextFrame.HasText = msoTrue Then
For Each hprLink In shpShape.TextFrame.TextRange.Hyperlinks
hprLink.Delete
Exit For
Next
Else
shpShape.Hyperlink.Delete
End If
End If
Next
Next
End Sub

Which compiles okay, but it doesn't seem to do anything. I need something that scans the entire document, all tables, text boxes etc. and strips the hyperlink AND the colored, underlined style, and leave the plaintext behind.

Thanks in advance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top