首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用chrome在excel中按顺序打开超链接

如何使用chrome在excel中按顺序打开超链接
EN

Stack Overflow用户
提问于 2016-06-22 22:07:03
回答 1查看 1.7K关注 0票数 0

我有一段代码,可以在chrome中打开excel表格中的超链接。它工作得很好,但是我注意到一个奇怪的行为,它不是按照从上到下的顺序打开超链接,而是使用一些我不理解的标准,因为当我测试时,我注意到它总是以相同的顺序打开链接,即

超链接1超链接2超链接3超链接4超链接5

它总是会打开的

超链接2超链接1超链接3超链接4超链接5

每次我运行代码时,它会按这个顺序打开它们,我需要它以从上到下的顺序打开超链接。以下是代码

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2016-06-24 02:11:41

Don't use .Select,因为它可能会导致问题。

这对你有效吗?

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37970491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档