【问题标题】:Follow dynamic hyperlink关注动态超链接
【发布时间】:2013-07-24 09:44:32
【问题描述】:

我有一个包含四列的工作表。 A 列有 ID 号,B 列有描述,C 列有位置,D 列有指向商品图片的链接。

我有一个宏,它要求用户输入 ID# 并搜索 A 列。消息框显示工具的位置。我希望在选择消息框上的“确定”按钮后,在新窗口中打开 D 列中的超链接。

这是我目前所拥有的。

Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter Tooling ID#")
If Trim(FindString) <> "" Then
    With Sheets("Sheet1").Range("A:A") 
        Set Rng = .Find(What:=FindString, _
                    After:=.Cells(.Cells.Count), _
                    LookIn:=xlValues, _
                    LookAt:=xlWhole, _
                    SearchOrder:=xlByRows, _
                    SearchDirection:=xlNext, _
                    MatchCase:=False)
        If Not Rng Is Nothing Then
            Application.Goto Rng, True 'value found
            MsgBox "Tooling " & Rng & " is located at " & Rng.Offset(, 2).Value & "."

        Else
            MsgBox "Tooling not found" 'value not found
        End If
    End With
End If

【问题讨论】:

  • 这看起来可以用 if、vlookup 和超链接工作表函数来完成,根本不需要任何宏。例如。 =if(not(isrr(vlookup(E1,A:C,3,false))),hyperlink(vlookup(E1,A:C,3,false),"工具位于 " &vlookup(E1,A:C ,3,false)),"Tooling not found"),其中 e1 是用户输入工具 ID#

标签: excel vba hyperlink excel-2010


【解决方案1】:

跟随超链接并在新窗口中打开它(真):

    Range("A8").Hyperlinks(1).Follow (True)

它应该在适当的应用程序中打开。

Hyperlink.Follow

如果 if 未配置为在适当的应用程序中打开,则您可以从单元格中读取链接地址并使用 Shell 进行调查以启动,例如,Paint:

Shell "MSPaint ""F:\Documents and Settings\student\My Documents\My Pictures\blog1.png"""

【讨论】:

    猜你喜欢
    • 2014-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-15
    • 2019-11-08
    相关资源
    最近更新 更多