更新Excel文件中的所有链接

我有Excel文件,其中包含一个大的信息列表,一列是我的硬盘中的文件的URL链接。 但硬盘名称从F更改为G,并且所有链接都断开。 我可以以简单的方式更新链接,而无需编写完成此任务的新应用程序。

例

像这样的VBA可以工作:

Sub HyperLinkChange() Dim oldtext As String Dim newtext As String Dim h As Hyperlink oldtext = "F:\" newtext = "G:\" For Each h In ActiveSheet.Hyperlinks x = InStr(1, h.Address, oldtext) If x > 0 Then h.Address = Application.WorksheetFunction. _ Substitute(h.Address, oldtext, newtext) End If Next End Sub