I am trying to run a small script that is intended to change part of the hyperlink address of all hyperlinks in an excel sheet (there are a few hundred links that are now pointing to the wrong server, i.e. the file names will be maintaned, but the server path needs to be changed). I have tried two different scripts, both produce the same error, "Run-time error '7': Out of memory". The scripts look like this:
Sub ChangeHyperlinks()
Dim hl As Hyperlink
For Each hl In ActiveSheet.Hyperlinks
hl.Address = Replace(hl.Address, "../../oldpath/", "../../newpath/")
Next
End Sub
and
Sub ChangeHyperlinks2()
Dim OldStr As String, NewStr As String
OldStr = "../../oldpath/"
NewStr = "../../newpath/"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub
Both of them error in the Replace part. Anybody got an idea?
Moderator Note:
Pls use code tags around your code next time as per forum rules.
Bookmarks