VBA使用默认浏览器访问网页声明及函数使用
'Use Default Broswer Open website
'-----------------------------------------------------------------------------------------------------------
'https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea?redirectedfrom=MSDN
'HINSTANCE ShellExecuteA(
' [in, optional] HWND hwnd,
' [in, optional] LPCSTR lpOperation,
' [in] LPCSTR lpFile,
' [in, optional] LPCSTR lpParameters,
' [in, optional] LPCSTR lpDirectory,
' [in] INT nShowCmd
');
'Target Platform Windows
'DLL Shell32.dll (version 3.51 or later)
'-----------------------------------------------------------------------------------------------------------
'Mr.Liu Note:
'NameCanBeDefinedByUsr: ShellExecute
' hwnd
' IpOperation
' IpFile
' IpParameters
' IpDirectory
' nShowCmd
'-----------------------------------------------------------------------------------------------------------
Private Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal IpOperation As String, _
ByVal IpFile As String, _
ByVal IpParameters As String, _
ByVal IpDirectory As String, _
ByVal nShowCmd As Long) As Long
'Example: IAccessWebPage("https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea?redirectedfrom=MSDN")
Public Sub IAccessWebPage(webAddress As String)
On Error Resume Next
ShellExecute 0&, vbNullString, webAddress, vbNullString, vbNullString, vbNormalFocus
End Sub