The following function will open a URL (here my web page) in your default browser when called from the macro GetWebPage. ****
It will not run in a PDF file.
Call the GetWebPage macro from your button,
Option Explicit
'Graham Mayor – https://www.gmayor.com – Last updated – 26 Oct 2021
Private pWebAddress As String
#If VBA7 Then
Private 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
Public Sub NewShell(cmdLine As String, lngWindowHndl As LongPtr)
ShellExecute lngWindowHndl, "open", cmdLine, "", "", 1
lbl_Exit:
Exit Sub
End Sub
#Else
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
Public Sub NewShell(cmdLine As String, lngWindowHndl As Long)
ShellExecute lngWindowHndl, "open", cmdLine, "", "", 1
lbl_Exit:
Exit Sub
End Sub
#End If
Public Sub GetWebPage()
pWebAddress = "https://www.gmayor.com/"
Call NewShell(pWebAddress, 3)
lbl_Exit:
Exit Sub
End Sub