#If VBA7 Then
'對於 64 位系統
Private Declare PtrSafe 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
#Else
'對於 32 位系統
Private 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
#End If
Private Sub OpenURL1() '第一種開啟網頁方式
網址 = "https://tw.yahoo.com"
ShellExecute 0, "open", 網址, vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
Private Sub OpenURL2() '第二種開啟網頁方式
網址 = "https://tw.yahoo.com"
Excel.Application.ActiveWorkbook.FollowHyperlink 網址
End Sub
'IE瀏覽器
Private Sub OpenURL3() '第三種開啟網頁方式
網址 = "https://tw.yahoo.com"
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate 網址
End With
End Sub
'Edga瀏覽器
Private Sub OpenURL4() '第四種開啟網頁方式
網址 = "https://tw.yahoo.com"
Dim sCmd As String
sCmd = "start microsoft-edge:" & 網址
Shell "cmd /c """ & sCmd & """", vbHide
End Sub