作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含数千行的电子表格。每行包含一个带有路径的超链接。
该路径无效,但是可以通过将其第一部分替换为正确的值来轻松修复。
Example: current hyperlink: F:\Help\index.html
Needed: P:\SystemHelp\index.html
问题在于标准查找/替换无法“查看”超链接的内容。
这是编写宏的唯一方法还是还有其他方法?
最佳答案
嘿 cnx.org,重新发明替换功能的方法。
Sub FindReplaceHLinks(sFind As String, sReplace As String, _
Optional lStart As Long = 1, Optional lCount As Long = -1)
Dim rCell As Range
Dim hl As Hyperlink
For Each rCell In ActiveSheet.UsedRange.Cells
If rCell.Hyperlinks.Count > 0 Then
For Each hl In rCell.Hyperlinks
hl.Address = Replace(hl.Address, sFind, sReplace, lStart, lCount, vbTextCompare)
Next hl
End If
Next rCell
End Sub
Sub Doit()
FindReplaceHLinks "F:\help\", "F:\SystemHelp\"
End Sub
关于Excel超链接批量更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2805046/
我是一名优秀的程序员,十分优秀!