Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2011, 02:43 PM
Philcraig69 Philcraig69 is offline Help with Word macro please Windows 7 64bit Help with Word macro please Office 2003
Novice
Help with Word macro please
 
Join Date: Jan 2011
Posts: 2
Philcraig69 is on a distinguished road
Default Help with Word macro please

Hi,



I use this simple macro:

Dim alink As Field
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldHyperlink Then
alink.Unlink
End If
Next alink

to remove all hyperlinks from a document. Now I need to remove only the hyperlinks with the word APPLE in the url, and leave the others alone -- how would I modify the macro??
Thanks for any help!
Reply With Quote
  #2  
Old 01-21-2011, 03:41 PM
macropod's Avatar
macropod macropod is offline Help with Word macro please Windows 7 32bit Help with Word macro please Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Phil,

Try:
Code:
Dim alink As Field
For Each alink In ActiveDocument.Fields
  If alink.Type = wdFieldHyperlink Then
    If InStr(alink.Code.Text, "APPLE") > 0 Then alink.Unlink
  End If
Next alink
Note: when posting code, please use code tags
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-21-2011, 04:19 PM
Philcraig69 Philcraig69 is offline Help with Word macro please Windows 7 64bit Help with Word macro please Office 2003
Novice
Help with Word macro please
 
Join Date: Jan 2011
Posts: 2
Philcraig69 is on a distinguished road
Default

Appears to be working perfectly, thank you so much!!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print Macro in MS Word steve207 Word VBA 0 09-10-2010 02:11 AM
Help with Word macro please word macro username Swarv Drawing and Graphics 4 06-16-2010 09:05 AM
Word 2003 macro to Word 2007 to 2010 to... maruapo Word VBA 0 06-04-2010 03:43 PM
Word Macro Tutorial Jax Word VBA 0 04-27-2010 09:13 PM
Word macro weezypenguin Word 0 02-25-2010 01:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft