Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Eliminate hyperlinks
Message
 
À
04/03/2005 16:30:29
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Microsoft Office
Catégorie:
Word
Divers
Thread ID:
00992725
Message ID:
00992902
Vues:
24
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform