Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find internet explorer is installed using vba excel
Hi,
Is there any way I can find out whether Internet Explorer is installed in machine using VBA? I already have a code in which I can open hyperlink using VBA but one of my test machine has mac which doesnot have IE. I need to add the error handling that If IE is not installed then Use the Safari instead of IE. Help would be appreciated. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find internet explorer is installed using vba excel
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 -- If this post helps click Yes --------------- Jacob Skaria "VJ" wrote: Hi, Is there any way I can find out whether Internet Explorer is installed in machine using VBA? I already have a code in which I can open hyperlink using VBA but one of my test machine has mac which doesnot have IE. I need to add the error handling that If IE is not installed then Use the Safari instead of IE. Help would be appreciated. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find internet explorer is installed using vba excel
You could try:
Dim ie As Object On Error Goto NoIE Set ie = CreateObject("InternetExplorer.Application") On Error Goto 0 Goto BrowserOK NoIE: On Error Goto NoSafari Set ie = CreateObject("Safari.Application") Goto BrowserOK NoSafari: Msgbox "No Browser" Exit Sub BrowserOK: -- HTH, Bernie MS Excel MVP "VJ" wrote in message ... Hi, Is there any way I can find out whether Internet Explorer is installed in machine using VBA? I already have a code in which I can open hyperlink using VBA but one of my test machine has mac which doesnot have IE. I need to add the error handling that If IE is not installed then Use the Safari instead of IE. Help would be appreciated. Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find internet explorer is installed using vba excel
Thanks guys for your help.
Appreciate your efforts. "Bernie Deitrick" wrote: You could try: Dim ie As Object On Error Goto NoIE Set ie = CreateObject("InternetExplorer.Application") On Error Goto 0 Goto BrowserOK NoIE: On Error Goto NoSafari Set ie = CreateObject("Safari.Application") Goto BrowserOK NoSafari: Msgbox "No Browser" Exit Sub BrowserOK: -- HTH, Bernie MS Excel MVP "VJ" wrote in message ... Hi, Is there any way I can find out whether Internet Explorer is installed in machine using VBA? I already have a code in which I can open hyperlink using VBA but one of my test machine has mac which doesnot have IE. I need to add the error handling that If IE is not installed then Use the Safari instead of IE. Help would be appreciated. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel/VBA/Internet Explorer | Excel Programming | |||
Excel Macro cannot Run at Internet Explorer 6 | Excel Programming | |||
Internet Explorer & Excel | Excel Programming | |||
Internet Explorer Automation with Excel VBA | Excel Programming | |||
Calling an Excel Doc from Internet Explorer | Excel Programming |