Last active
April 26, 2021 15:46
-
-
Save JoeGlines/c6dbba25eacbe02e1301ba36582877a4 to your computer and use it in GitHub Desktop.
Automate searching and replacing hyperlinks in MS Word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;******************************************************* | |
; Want a clear path for learning AutoHotkey; Take a look at our AutoHotkey Udemy courses. They're structured in a way to make learning AHK EASY | |
; Right now you can get a coupon code here: https://the-Automator.com/Learn | |
;******************************************************* | |
;************************************** | |
OldString:="udeGU" | |
NewString:="nws" | |
;******************************************************* | |
;~ doc.ActiveDocument.Hyperlinks.Add(oWord.Selection.Range, Address,"","",TextToDisplay) ;what I started from | |
doc:=ComObjActive("Word.Application") ;Connect to open Word file | |
loop, % doc.ActiveDocument.Hyperlinks.count { | |
oldLink:=doc.ActiveDocument.Hyperlinks[a_index].Address ; the original address | |
doc.ActiveDocument.Hyperlinks[a_index].Address :=StrReplace(oldLink,OldString,NewString) | |
} | |
MsgBox % "performed " doc.ActiveDocument.Hyperlinks.count " replacements" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment