我想寫一個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函數的包裝。 –