I have found a way to use VBA to change certain parts of hyperlinks using the following code:
Sub Button1_Click()
Dim OldStr As String, NewStr As String
OldStr = "C:\Users\mackdad123\Documents\Maps\AtlantaGeorgia\Georgia\DRF"
NewStr = "C:\Users\harrysmith\Document\Maps\AtlantaGeorgia\Georgia\DRF"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub
However, this will only work if I try to change anything within this section of the string: "Documents\Maps\AtlantaGeorgia\Georgia\DR". And I am needing to change the username "mackdad123" to "harrysmith."
I think I've found out the reason for this is because in excel, when you click on 'edit hyperlink,' it does not show the entire address in the edit bar, it only shows "..\Documents\Maps\AtlantaGeorgia\Georgia\DRF". So this code cannot change anything that exists before "documents".
I attempted to run this code as a test, and it changed "..\Documents" to "Desktop\???Documents"
Sub Button1_Click()
Dim OldStr As String, NewStr As String
OldStr = "..\Documents"
NewStr = "???Documents"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub
My question is how can I either show the entire address in the edit hyperlink bar, or is there another way I can change the user name of this address? Thanks
Bookmarks