Wie kann ich den Standardbrowser mit einer URL aufrufen?
Diese drei Varianten rufen die Adresse im Browser auf und bringen das Browserfenster nach vorn:
Sub URL_Aufruf() ActiveWorkbook.FollowHyperlink Address:="https://www.joerglorenz.de", NewWindow:=True, AddHistory:=True Application.WindowState = xlMaximized End Sub
Oder:
Sub URL_Aufruf1() Dim WSHShell As Object Set WSHShell = CreateObject("WScript.Shell") WSHShell.Run "https://joerglorenz.de" End Sub
Oder:
'Deklaration muss am Anfang des Moduls stehen: #If VBA7 Then Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongPtr) As LongPtr #Else 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 #End If Sub URL_Aufruf2() Dim lngRet As LongPtr lngRet = ShellExecute(0, "Open", "https://joerglorenz.de", "", "", 5) End Sub