Insert a new module and paste the below code.
Sub Macro()
If IsIEAvailable Then
'Use IE
Else
'Use Safari
End If
End Sub
Option Explicit
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal ulOptions As Long, ByVal samDesired As Long, _
phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
As String, ByVal lpReserved As Long, lpType As Long, _
lpData As Any, lpcbData As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const ERROR_SUCCESS = 0&
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const SYNCHRONIZE = &H100000
Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE _
Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or _
KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) _
And (Not SYNCHRONIZE))
Public Function IsIEAvailable() As Boolean
Dim hKeyOpen As Long
Dim lKeyResult As Long
Dim lKeyQueryLen As Long
lKeyResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths" _
& "\\IEXPLORE.EXE" & Chr$(0), &H0, KEY_ALL_ACCESS, hKeyOpen)
lKeyResult = RegQueryValueEx(hKeyOpen, "Path", 0&, 0&, 0&, _
lKeyQueryLen)
If lKeyQueryLen > 0 Then
IsIEAvailable = True
Else
IsIEAvailable = False
End If
RegCloseKey hKeyOpen
End Function