[英]How to open hyperlinks in excel in order using chrome
我有一个代码可以从chrome的excel表格中打开超链接。 它工作正常,但是我注意到一个奇怪的行为,它不是按照从上到下的顺序打开超链接,而是使用一些标准,我不明白它不是随机的,因为在测试时我注意到它总是以相同的顺序打开链接即
超链接1超链接2超链接3超链接4超链接5
它会一直打开
超链接2超链接1超链接3超链接4超链接5
每次我运行代码时,它都以这种顺序打开它们,我需要它以从上到下的顺序打开超链接。 这是代码
Sub Open_HyperLinks()
Dim chromePath As String, hl As Hyperlink
chromePath = Environ("PROGRAMFILES(X86)") & "\Google\Chrome\Application\chrome.exe"
If Selection.Count > 1 Then
Selection.SpecialCells(xlCellTypeVisible).Select
End If
'On Error Resume Next
For Each hl In Selection.Hyperlinks
Shell chromePath & " -url " & hl.Address
Next hl
End Sub
不要使用.Select
,因为它可能会引起问题。
这对您有用吗?
Sub Open_HyperLinks()
Dim chromePath As String, hl As Hyperlink
Dim rng As Range, visRng As Range
chromePath = Environ("PROGRAMFILES(X86)") & "\Google\Chrome\Application\chrome.exe"
Set rng = Selection
If rng.Count > 1 Then
Set visRng = rng.SpecialCells(xlCellTypeVisible)
End If
'On Error Resume Next
For Each hl In visRng.Hyperlinks
Shell chromePath & " -url " & hl.Address
Next hl
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.