在excel里做了很多超链接,而且链接的都是本地的相对路径文件,可惜不知怎么的,它会自动变成绝对路径,这样就引起访问时找不到正确路径,故通过VBA批处理的方法把它全部改回来,如下:
Dim oldfile As String
Dim Newfile As String
Sub RemoveHyperLinks()
oldfile = "D:\Administrator\Application Data\Microsoft\Excel\" '需要替换的旧文件名
Newfile = "" '替换成的新文件名
For Each hlink In Cells.Hyperlinks
hlink.Address = Replace(hlink.Address, oldfile, Newfile)
Next
End Sub
Dim oldfile As String
Dim Newfile As String
Sub RemoveHyperLinks()
oldfile = "D:\Administrator\Application Data\Microsoft\Excel\" '需要替换的旧文件名
Newfile = "" '替换成的新文件名
For Each hlink In Cells.Hyperlinks
hlink.Address = Replace(hlink.Address, oldfile, Newfile)
Next
End Sub
本文介绍了一个使用VBA脚本来批量处理Excel文件,将自动转换为绝对路径的本地相对路径超链接恢复为相对路径的方法。
2006

被折叠的 条评论
为什么被折叠?



