![]() |
Change hyperlink address
Hi all, I have in my excel document an hyperlink to a word document. If the word document is moved to another place in the computer, the hyperlink doesn't work anymore. If the hyperlink cannot be find, is there a way to change its address using VBA ? with a window like "open document" where you can search the file that you want to open? Many thanks Sibilia -- Sibilia ------------------------------------------------------------------------ Sibilia's Profile: http://www.excelforum.com/member.php...o&userid=21363 View this thread: http://www.excelforum.com/showthread...hreadid=392325 |
Change hyperlink address
I don't know how you would trap the error when a file has been moved but what
you could do is check all hyperlinks on a sheet when it is activated. If any are found which wil fail then a prompt will allow you to assign a new file. Private Sub Worksheet_Activate() Dim Hpr As Hyperlink Dim hAdr As String Dim newLink As Variant Dim fndAdr As String Dim nTitle As String For Each Hpr In Me.Hyperlinks hAdr = Hpr.Address fndAdr = Dir(hAdr) If fndAdr = "" Then nTitle = "Select file for hyperlink: " & Hpr.Name newLink = Application.GetOpenFilename(, , nTitle) If newLink = False Then Else Hpr.Address = newLink End If End If Next Hpr End Sub This is worksheet event code: right click the sheet tab, select view code and paste in there. Hope this helps Rowan "Sibilia" wrote: Hi all, I have in my excel document an hyperlink to a word document. If the word document is moved to another place in the computer, the hyperlink doesn't work anymore. If the hyperlink cannot be find, is there a way to change its address using VBA ? with a window like "open document" where you can search the file that you want to open? Many thanks Sibilia -- Sibilia ------------------------------------------------------------------------ Sibilia's Profile: http://www.excelforum.com/member.php...o&userid=21363 View this thread: http://www.excelforum.com/showthread...hreadid=392325 |
All times are GMT +1. The time now is 04:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com