我想写一个VBA脚本,需要一个电子邮件地址,然后在新窗口中打开它。诀窍是我需要让它在不使用Shell32.dll的情况下运行。VBA - 替代使用Shell32.dll
根据下面的代码,是否有其他方法来重写以下内容?
Option Explicit
Private Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" (_
ByVal hWnd As Long, _
ByVal Operation As String, _
ByVal Filename As String, _
Optional ByVal Parameters As String, _
Optional ByVal Directory As String, _
Optional ByVal WindowStyle As Long = vbMinimizedFocus _
) As Long
Public Sub OpenUrl()
Dim olItem As Outlook.MailItem
Set olItem = Application.ActiveExplorer().Selection(1)
Dim sTemp As String
Dim sURL As String
If olItem.SenderEmailType = "EX" Then
sTemp = olItem.Sender.GetExchangeUser().PrimarySmtpAddress
Else
sTemp = olItem.SenderEmailAddress
End If
sURL = "https://afakeurl.com/" + sTemp
Dim lSuccess As Long
lSuccess = ShellExecute(0, "Open", sURL)
End Sub
使用VB的Shell函数......这基本上是一个Win32 API函数的包装。 –