关注动态超链接

问题描述 投票:0回答:1

我有一个包含四列的工作表。列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
excel vba excel-vba hyperlink excel-2010
1个回答
0
投票

要关注超链接并在新窗口中打开它(True):

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

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

Hyperlink.Follow

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

Shell "MSPaint ""F:\Documents and Settings\student\My Documents\My Pictures\blog1.png"""
© www.soinside.com 2019 - 2024. All rights reserved.