Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Eliminate hyperlinks
Message
 
To
04/03/2005 16:30:29
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Microsoft Office
Category:
Word
Miscellaneous
Thread ID:
00992725
Message ID:
00992902
Views:
23
I've done a lot of VBA, but only in Excel and I've seen something similar to this happen. In Excel, if you want to delete certain rows of colimns, you have to start with the last and loop towards the first row or column because the numbers change as you're deleting them.

Same for the links in this case. Delete the first one and number 2 becomes number 1. The loop goes on to delete number 2, but the new number 2 was originally number 3.

>>You should be able to do it by iterating through all the hyperlinks in a range and calling the Delete method, which appears to remove the link while leaving the text in place. Rough example to handle entire document (easy to change):
>>
>>oWd = CREATEOBJECT("Word.Application")
>>oDoc = oWd.Documents.Open(GETFILE("doc"))
>>oLinks = oDoc.Range.Hyperlinks
>>FOR EACH oLink IN oLinks
>>  oLink.Delete
>>ENDFOR
>>oDoc.SaveAs( ...  && or Save() to overwrite
>>
>
>While I was looking for a Word-only solution (to assist a client), I really like the idea.
>
>But in your code, something unexpected happens: only links #1, 3, 5, etc. are deleted. It seems that deleting a link will get Word confused about the links collection!
___________________________
Kenneth Wonderley
http://www.wonderley.com


...the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness and self-control.
Galatians 5:22 & 23
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform