excel批量把超链接的绝对路径改为相对路径

来源:互联网 发布:java future实现原理 编辑:程序博客网 时间:2024/05/16 01:52
在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
原创粉丝点击