询问用户打开超链接的应用程序

时间:2016-05-26 13:44:28

标签: excel excel-vba vba

有人知道如何在点击特定类型的超链接时提示用户在两个应用程序之间进行选择(以便打开相关文件)吗? 我想这与application.open ..

有关

1 个答案:

答案 0 :(得分:0)

如果您知道这两个应用程序的路径,则可以执行shell命令

Sub app1_Click()
    openInApplication("C:\Path\to\app1", hyperLink)
End Sub

Sub app2_Click()
    openInApplication("C:\Path\to\app2", hyperLink)
End Sub

Sub openInApplication(pathToApp as String, hyperLink as String)
    If Dir(pathToApp) = "" Then
        MsgBox "Path Not Found", vbCritical, "Macro Ending"
        Exit Sub
    End If

    Shell """" & pathToApp & """" & hyperLink
End Sub