Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
How to change the following line to default web browser:
VB
Dim WebBrowser1 as object = CreatObject("InternetExplorer.Application")


What I have tried:

VB
1. Dim WebBrowser1 as object = CreatObject("LaunchWinApp.exe %1")
2. Dim WebBrowser1 as object = CreatObject("default")
Posted
Updated 15-Oct-18 1:34am
v2

You don't. AFAIK, IE is the only browser exposed through a COM interface.

Next, treating the returned class object from CreateObject "As Object", will only get you access to the methods and properties that an Object exposes, not the properties and methods of the returned class object you created.

If you want to control all of the major browsers, look into Selenium[^].
 
Share this answer
 
Comments
Alex Steinmetz 15-Oct-18 6:56am    
Thanks Dave for your imm. answer.
you have saved me a lot of time of testing.

Selenium do not support VB.
Dave Kreskowiak 15-Oct-18 8:26am    
What makes you say it's not supported?

It works in VB.NET.
[EDITED]
Use this code (VBS/VBA) to open a URL with standard browser:

VB
Dim webbrowser2
Set webbrowser2 = CreateObject("Wscript.Shell")
If webbrowser2 Is Nothing Then
  MsgBox "Error on creating WebBrowsewr object"
Else
  webbrowser2.Run "http:\\www.google.com", 1, False
End If


Take a look: Script Show default browser (updated for Win10)[^]

wscript.echo browser 
 
' Indentify default web browser 
' By Jørgen Bigom  
' Updated Oct. 2015 
Function Browser 
    Const HKEY_CURRENT_USER = &H80000001 
    Const strKeyPath = "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" 
    Const strValueName = "Progid" 
    Dim strValue, objRegistry, i 
' Browser list: 
    Dim blist(6,1) 
    blist(0,0) = "Intermet Explorer"    : blist(0,1) = "ie" 
    blist(1,0) = "Edge"                    : blist(1,1) = "appxq0fevzme2pys62n3e0fbqa7peapykr8v" 
    blist(2,0) = "Firefox"                : blist(2,1) = "firefox" 
    blist(3,0) = "Chrome"                : blist(3,1) = "chrome" 
    blist(4,0) = "Safari"                : blist(4,1) = "safari" 
    blist(5,0) = "Avant"                : blist(5,1) = "browserexeurl" 
    blist(6,0) = "Opera"                : blist(6,1) = "opera" 
    Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv") 
    objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue 
    If IsNull(strValue) Then 
        browser = "Intermet Explorer (Windows standard)": Exit Function 
    Else 
        For i = 0 To Ubound (blist, 1) 
            If Instr (1, strValue, blist(i,1), vbTextCompare) Then browser = blist(i,0) & " - User choice": Exit Function 
        Next 
    End If 
    browser = "Unknown web browser! (signature: '" & strValue & "')" 
End Function
 
Share this answer
 
v2
Comments
Dave Kreskowiak 17-Oct-18 8:25am    
This has nothing to do with the question that was asked.
Leo Chapiro 18-Oct-18 10:46am    
This is the possibility to get the staandard browser by using the windows registry. Why should that not to be relevant to asked question?
Dave Kreskowiak 18-Oct-18 11:54am    
My bad. This is what I get for trying to read code with half my brain asleep.
Alex Steinmetz 18-Oct-18 13:43pm    
_dude
Can you be more specific.

Looks like you all missing the main point.
I am not trying to control all of the major browsers.

what I am trying is to run the default browser as: "Process.Start(url)"

and get the HtmlDocuments and the active elements

so I can post my UserName and Password.
Leo Chapiro 18-Oct-18 14:33pm    
@Alex: Have you tried call WShell.Run(url, 1, false) ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900