是否可以在Excel中停止关注超链接?我非常愿意使用宏和其他方法。经过数小时的搜索,我发现了以下类型的“解决方案”,但它们不起作用:
这些不起作用,因为我没有工作表。我的工作是使用用户公式或子系统自动化我的同事的报告/操作/计算。工作表的所有者在文件中包含许多链接,他们希望保留这些链接。我不能随意删除他们的链接。但是对我来说故障排除和编程很困难,因为我有时候(通常不会使用键盘进行导航,但有时候)会不小心点击一个链接,然后会出现弹出窗口和所有垃圾。我也无法创建虚拟工作表,因为工作表包含大约10,000行数据,我担心它会膨胀文件大小。任何帮助,将不胜感激!谢谢!
答案 0 :(得分:0)
这将从您选择的选项中删除超链接。
Sub removelinks()
Dim rng As Range
For Each r In Selection
rng.Hyperlinks.Delete
Next
End Sub
答案 1 :(得分:0)
我假设您要在处理文件时暂时禁用超链接,然后在完成后重新启用它们。一种可能的解决方案是将它们存储在单独的临时表中。
Sub DisableLinks()
Dim ws As Worksheet
Dim ts As Worksheet
Set ts = ActiveSheet
Set ws = Worksheets.Add(after:=ts)
Dim hylink As Hyperlink
Dim destlink As Hyperlink
For Each hylink In ts.Hyperlinks
If hylink.Range.Value <> "" Then
ws.Range(hylink.Range.Address) = hylink.Range.Value
If hylink.SubAddress = "" Then
Set destlink = ws.Hyperlinks.Add(anchor:=ws.Range(hylink.Range.Address), Address:=hylink.Address, TextToDisplay:=hylink.TextToDisplay)
Else
ws.Hyperlinks.Add anchor:=ws.Range(hylink.Range.Address), Address:=hylink.Address, SubAddress:=hylink.SubAddress, TextToDisplay:=hylink.TextToDisplay
End If
hylink.Delete
End If
Next hylink
ws.Visible = xlVeryHidden
End Sub
Sub RestoreLinks()
Dim ws As Worksheet
Dim ts As Worksheet
Set ts = ActiveSheet
Set ws = Worksheets(ts.Index + 1)
ws.Visible = xlSheetVisible
Dim hylink As Hyperlink
For Each hylink In ws.Hyperlinks
If hylink.Range.Value <> "" Then
If hylink.SubAddress = "" Then
ts.Hyperlinks.Add anchor:=ts.Range(hylink.Range.Address), Address:=hylink.Address, TextToDisplay:=hylink.TextToDisplay
Else
ts.Hyperlinks.Add anchor:=ts.Range(hylink.Range.Address), Address:=hylink.Address, SubAddress:=hylink.SubAddress, TextToDisplay:=hylink.TextToDisplay
End If
hylink.Delete
End If
Next hylink
ws.Delete
End Sub