Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does anyone know how to read/find the current users default browser via VBA?
(Internet Explorer, Google Chrome, Mozilla Firefox, Apple Safari, Opera Browser, etc...) I'm not talking about opening a website in the default browser, but finding out which browser the current user is using as the default one... I'm guessing it must be somewhere in the Registry, under HKEY_CURRENT_USER, since all users on the same computer are allowed to have their own choice of default browser - but where? A search on Google didn't help, but perhaps, I shouldn't get it from the Registry at all??? So, how to tell which browser is the default one? TIA, CE --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi Charlotte,
Sub CheckWebOptions() Dim wkbOne As Workbook Set wkbOne = Application.Workbooks(1) ' Determine the target browser. Select Case wkbOne.WebOptions.TargetBrowser Case msoTargetBrowserIE6: MsgBox "The target browser is IE6." Case msoTargetBrowserIE5: MsgBox "The target browser is IE5." Case msoTargetBrowserIE4: MsgBox "The target browser is IE4." Case msoTargetBrowserV4: MsgBox "Microsoft Internet Explorer 4.0, Netscape Navigator 4.0." Case msoTargetBrowserV3: MsgBox "Microsoft Internet Explorer 3.0, Netscape Navigator 3.0." Case Else: MsgBox "The target browser is not in the given list" End Select End Sub isabelle Le 2014-04-27 08:18, Charlotte E. a écrit : Does anyone know how to read/find the current users default browser via VBA? (Internet Explorer, Google Chrome, Mozilla Firefox, Apple Safari, Opera Browser, etc...) I'm not talking about opening a website in the default browser, but finding out which browser the current user is using as the default one... I'm guessing it must be somewhere in the Registry, under HKEY_CURRENT_USER, since all users on the same computer are allowed to have their own choice of default browser - but where? A search on Google didn't help, but perhaps, I shouldn't get it from the Registry at all??? So, how to tell which browser is the default one? TIA, CE --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Isabelle, but it doesn't tell me, if it is Chrome, Firefox, Safari,
or another browser, but only support IE... ....and, since Windows know the default browser, it must be possible to get it in VBA also. (I did know about that one - as I said, I've already looked around the net myself) Thanks for your effort anyway :-) CE "isabelle" wrote in message ... hi Charlotte, Sub CheckWebOptions() Dim wkbOne As Workbook Set wkbOne = Application.Workbooks(1) ' Determine the target browser. Select Case wkbOne.WebOptions.TargetBrowser Case msoTargetBrowserIE6: MsgBox "The target browser is IE6." Case msoTargetBrowserIE5: MsgBox "The target browser is IE5." Case msoTargetBrowserIE4: MsgBox "The target browser is IE4." Case msoTargetBrowserV4: MsgBox "Microsoft Internet Explorer 4.0, Netscape Navigator 4.0." Case msoTargetBrowserV3: MsgBox "Microsoft Internet Explorer 3.0, Netscape Navigator 3.0." Case Else: MsgBox "The target browser is not in the given list" End Select End Sub isabelle Le 2014-04-27 08:18, Charlotte E. a écrit : Does anyone know how to read/find the current users default browser via VBA? (Internet Explorer, Google Chrome, Mozilla Firefox, Apple Safari, Opera Browser, etc...) I'm not talking about opening a website in the default browser, but finding out which browser the current user is using as the default one... I'm guessing it must be somewhere in the Registry, under HKEY_CURRENT_USER, since all users on the same computer are allowed to have their own choice of default browser - but where? A search on Google didn't help, but perhaps, I shouldn't get it from the Registry at all??? So, how to tell which browser is the default one? TIA, CE --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Charlotte E. wrote:
Does anyone know how to read/find the current users default browser via VBA? (Internet Explorer, Google Chrome, Mozilla Firefox, Apple Safari, Opera Browser, etc...) I'm not talking about opening a website in the default browser, but finding out which browser the current user is using as the default one... I'm guessing it must be somewhere in the Registry, under HKEY_CURRENT_USER, since all users on the same computer are allowed to have their own choice of default browser - but where? A search on Google didn't help, but perhaps, I shouldn't get it from the Registry at all??? So, how to tell which browser is the default one? Under Windows 7 & 8 (and probably Vista & 8.1): HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell \Associations \UrlAssociations\http\UserChoice\ProgID This points to an entry under HKEY_CLASSES_ROOT -- for example, in my Win8 install, it's "IE.HTTP", while in my Win7 install it's "Opera.Protocol". Under Windows XP (and 2000, if you need to support it): HKEY_CURRENT_USER\Software\Classes\http\shell\open \command There's a different key used for what's listed on XP's start menu, but I don't remember what it is. Google should know, if you need it. Under Win9x & NT4 (if you need to support *those*): HKEY_CLASSES_ROOT\http\shell\open\command -- In life, they were a motley crew: farmers, lords, cutpurses, priests. In death, they are united in a singular, benevolent purpose. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's how I check to see what MSO apps are installed...
Const sNames$ = "Internet Explorer,Firefox,Chrome" Dim oApp As Object, sz For Each sz In Split(sNames, ",") Set oApp = CreateObject(sz & ".Application") If Not oApp Is Nothing Then Beep: Exit For Next 'sz ...but that won't tell you the default browser. I'm curious why you need to know this because passing a URL in ShellExecute() opens in the user's default browser. I suppose you could do this and query its window title for the browser name, though! -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
GS wrote:
Here's how I check to see what MSO apps are installed... Const sNames$ = "Internet Explorer,Firefox,Chrome" Dim oApp As Object, sz For Each sz In Split(sNames, ",") Set oApp = CreateObject(sz & ".Application") If Not oApp Is Nothing Then Beep: Exit For Next 'sz ..but that won't tell you the default browser. I'm curious why you need to know this because passing a URL in ShellExecute() opens in the user's default browser. I suppose you could do this and query its window title for the browser name, though! Maybe documentation that was written differently for various browsers? -- There are some prices that *nobody* should be willing to pay. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does anyone know how to read/find the current users default browser via
VBA? Without reading the registry can use FindExecutable but it needs a file with an appropriate extension, simplified example ' adapt for 64bit office Private Declare Function FindExecutable Lib "shell32" _ Alias "FindExecutableA" _ (ByVal lpFile As String, _ ByVal lpDirectory As String, _ ByVal sResult As String) As Long Sub Test() Dim pos As Long Dim sExt As String Dim sFile As String Dim sPath As String Dim lReturn As Long Dim sResult As String sExt = "html" sPath = Application.DefaultFilePath & "\" sFile = DummyFile(sPath, sExt, True) If Len(sFile) = 0 Then ' problem creating file ? Else sResult = Space$(260) lReturn = FindExecutable(sFile, sPath, sResult) If lReturn = 32 Then pos = InStr(sResult, Chr$(0)) MsgBox Left$(sResult, pos - 1) Else MsgBox "Error code: " & lReturn End If End If DummyFile sPath, sExt, False End Sub Function DummyFile(sPath As String, sExt As String, bCreate As Boolean) As String Dim sFile As String Dim ff As Long sFile = sPath & "Dummy." & sExt On Error Resume Next Kill sFile On Error GoTo errExit ff = FreeFile Open sFile For Append As #ff Print #ff, "dummy file" Close #ff DummyFile = "Dummy." & sExt errExit: End Function Regards, Peter T |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Awesome, Peter - it works :-)
And, not only does it tell you the browser, but also the full path to the browser... And, I've tested it with all five major browsers: Chrome, Firefox, MSIE, Opera and Safari.. And, Opera and Safari, I even tried to install on some VERY unlikely loctions :-) And, tested on both a Danish Windows 7, an English Windows XP, and even on a Windows Server OS :-) And, it was tested on XL2003, XL2007, XL2010 and XL2013 - and, also in both Danish and English versions. So, not matter the browser, the installation, the Excel, the language or the OS - it just works :-) Thanks, Peter - you saved my day :-) CE "Peter T" wrote in message ... Does anyone know how to read/find the current users default browser via VBA? Without reading the registry can use FindExecutable but it needs a file with an appropriate extension, simplified example ' adapt for 64bit office Private Declare Function FindExecutable Lib "shell32" _ Alias "FindExecutableA" _ (ByVal lpFile As String, _ ByVal lpDirectory As String, _ ByVal sResult As String) As Long Sub Test() Dim pos As Long Dim sExt As String Dim sFile As String Dim sPath As String Dim lReturn As Long Dim sResult As String sExt = "html" sPath = Application.DefaultFilePath & "\" sFile = DummyFile(sPath, sExt, True) If Len(sFile) = 0 Then ' problem creating file ? Else sResult = Space$(260) lReturn = FindExecutable(sFile, sPath, sResult) If lReturn = 32 Then pos = InStr(sResult, Chr$(0)) MsgBox Left$(sResult, pos - 1) Else MsgBox "Error code: " & lReturn End If End If DummyFile sPath, sExt, False End Sub Function DummyFile(sPath As String, sExt As String, bCreate As Boolean) As String Dim sFile As String Dim ff As Long sFile = sPath & "Dummy." & sExt On Error Resume Next Kill sFile On Error GoTo errExit ff = FreeFile Open sFile For Append As #ff Print #ff, "dummy file" Close #ff DummyFile = "Dummy." & sExt errExit: End Function Regards, Peter T --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Charlotte E." wrote in message
Awesome, Peter - it works :-) Glad it works but just seen a stupid omission in the DummyFile routine. Add the If bCreate pair. Whole point of course being to delete the file when done, not recreate it again! Function DummyFile(sPath As String, sExt As String, bCreate As Boolean) As String Dim sFile As String Dim ff As Long sFile = sPath & "Dummy." & sExt On Error Resume Next Kill sFile On Error GoTo errExit If bCreate Then ff = FreeFile Open sFile For Append As #ff Print #ff, "dummy file" Close #ff End If DummyFile = "Dummy." & sExt errExit: End Function |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Charlotte E." wrote in message
Awesome, Peter - it works :-) Glad it works but just seen a stupid omission in the DummyFile routine. Add the If bCreate pair. Whole point of course being to delete the file when done, not recreate it again! Function DummyFile(sPath As String, sExt As String, bCreate As Boolean) As String Dim sFile As String Dim ff As Long sFile = sPath & "Dummy." & sExt On Error Resume Next Kill sFile On Error GoTo errExit If bCreate Then ff = FreeFile Open sFile For Append As #ff Print #ff, "dummy file" Close #ff End If DummyFile = "Dummy." & sExt errExit: End Function I was going to suggest same, but thinking this function isn't really necessary if you have a list of executable filenames!<g -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
but thinking this function isn't really necessary if you have a list
of executable filenames Uh.., I stand corrected if one doesn't already have a procedure for creating files! Since I already have this the 'Kill' statement would be included in the 'GetExecutable$()' function so it runs stand-alone and callable to return the info. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Nice!
-- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Change Default Hyperlink Browser..? | Excel Programming | |||
Default ribbon to open by default when opening xls in browser | Excel Discussion (Misc queries) | |||
Excel default browser for Win2003 | Excel Discussion (Misc queries) | |||
How do I change default browser for opening WWW links from Excel? | Setting up and Configuration of Excel | |||
Default browser for web querys? | Excel Programming |