【问题标题】:How to open hyperlinks in excel in order using chrome如何使用chrome在excel中按顺序打开超链接
【发布时间】:2022-04-01 03:52:37
【问题描述】:

我有一个代码可以从 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

【问题讨论】:

  • URL 存储在哪里/如何存储?在一个单元格中?我是一排还是一列?运行代码时 Chrome 是否关闭?
  • 每个超链接都存储在单个单元格中,例如超链接 1 在单元格 A1 中超链接 2 单元格 A2 等等... chrome 是打开的

标签: excel vba hyperlink


【解决方案1】:

Don't use .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

【讨论】:

  • 不,仍然没有打开它们我想知道我想要做的事情是否可行我尝试了Application.Wait Now() + TimeValue("00:00:01"),但仍然是相同的行为
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-01-11
  • 2021-07-29
  • 2018-06-29
  • 1970-01-01
  • 2013-01-03
  • 2020-11-30
  • 1970-01-01
相关资源
最近更新 更多