Existe-t-il une macro, un code VBA ou un script VBScript que je peux écrire pour modifier les URL de tous les hyperliens de mon document Word? Word 97-2003 ou format docx.Comment modifier par programme tous les liens hypertexte dans un document Word?
Répondre
Dim doc As Document
Dim link, i
'Loop through all open documents.
For Each doc In Application.Documents
'Loop through all hyperlinks.
For i = 1 To doc.Hyperlinks.Count
'If the hyperlink matches.
If LCase(doc.Hyperlinks(i).Address) = "http://www.yahoo.com/" Then
'Change the links address.
doc.Hyperlinks(i).Address = "http://www.google.com/"
'Change the links display text if desired.
doc.Hyperlinks(i).TextToDisplay = "Changed to Google"
End If
Next
Next
Voici un lien vers tous les Hyperlink Methods and Properties
A travaillé parfaitement. Merci. – jinsungy
M'a aussi aidé, merci! –
Cela ne fonctionne pas avec les images avec des hyperliens =/Savez-vous comment les obtenir? –
Cela m'a énormément aidé. L'utilisateur a ouvert Word Docs contenant des liens hypertexte via son lecteur mappé au lieu d'aller dans le long chemin à travers le réseau. Des centaines de docs seront sauvés!
J'utilise la fonction mid():
Sub FixMyHyperlink()
Dim doc As Document
Dim link, i
'Loop through all open documents.
For Each doc In Application.Documents
'Loop through all hyperlinks.
For i = 1 To doc.Hyperlinks.Count
'If the hyperlink matches.
If LCase(doc.Hyperlinks(i).Address) Like "*partOfHyperlinkHere*" Then
'Change the links address. Used wildcards (*) on either side.
doc.Hyperlinks(i).Address = Mid(doc.Hyperlinks(i).Address, 70,20) '
'Change the links display text if desired.
'doc.Hyperlinks(i).TextToDisplay = "Oatmeal Chocolate Chip Cookies"
End If
Next
Next
End Sub
Quel genre de modifications ne voulez-vous faire? Voulez-vous faire défiler chaque lien hypertexte ou faire le même changement à chacun? –
Fondamentalement, je veux faire un remplacement sur chaque lien hypertexte. Le nom du serveur de fichiers a changé. – jinsungy