[英]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.