gpt4 book ai didi

vba - 如何在电子邮件到达时启动 URL

转载 作者:行者123 更新时间:2023-12-01 09:11:29 26 4
gpt4 key购买 nike

我想在电子邮件到达 Outlook 时启动一个 URL。我设置了一个规则并让它触发一个脚本函数。看起来我想调用 ShellExecute 在浏览器中启动 URL,但是当我点击这一行时:

    ShellExecute(0&, "open", URL, vbNullString, vbNullString, _
vbNormalFocus)

方法未定义。有什么想法吗?

最佳答案

ShellExecute 是 windows dll 中的一个函数。您需要在 VBA 模块中为它添加这样的声明:

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Shell 解决方案与 ShellExecute 之间的区别在于 ShellExecute 将使用 URL 的默认系统处理程序来打开链接。这不一定是 IE。您的解决方案将始终在 IE 中打开它。您的相当于将 iexplore.exe 放入 Windows 的运行框中。 ShellExecute 相当于只是把 url 放到 windows 的运行框中。

关于vba - 如何在电子邮件到达时启动 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/619079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com