Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Calling Firefox MozillaBrowser from Visual Basic VB6

Posted on 2005-04-22
7
Medium Priority
?
5,729 Views
Last Modified: 2013-11-25
Hi,

I have a VB app that currently user IE InternetExplorer Browser which is call using the following commands.

Dim obj As InternetExplorer
Set obj = New InternetExplorer

I'm trying to use MozillaBrowser but it doesn't work in ny app the way that IE does. ere is what I have tried.

Dim obj As MozillaBrowser
Set obj = New MozillaBrowser
 or
Set obj = New MOZILLACONTROLLib.MozillaBrowser

Please help.
Thanks
Tom
0
Comment
Question by:Costellot
5 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 13847045
To my knowledge, the only way to automate Mozilla is through this Active X control:

http://www.iol.ie/~locka/mozilla/control.htm
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 13847100
If you have mozzila installed on your computer you can set the a string in the registry and set mozzila to be default and then set it back to IE when your finsished.

HKEY_CLASSES_ROOT\http\shell\open\command

default          "C:\Program Files\Internet Explorer\iexplore.exe" -nohome

You then just change the path to point the mozzila webbrowser location



'Registry code...


Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const ERROR_SUCCESS = 0&
Private Const REG_SZ = 1
Private Const REG_DWORD = 4
Private Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
    Dim keyhand As Long
    Dim X As Long
    Dim r As Long
    X = RegCreateKey(hKey, strPath, keyhand)
    X = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
    X = RegCloseKey(keyhand)
End Sub

Private Sub Command1_Click()
'set IE to default browser
Call SaveString(HKEY_CLASSES_ROOT, "http\shell\open\command", "", "C:\Program Files\Internet Explorer\iexplore.exe") ' string value
End Sub

Private Sub Command2_Click()
'set Mozilla to default browser
Call SaveString(HKEY_CLASSES_ROOT, "http\shell\open\command", "", "C:\Program Files\Mozilla\firefox.exe") ' string value

End Sub
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 13847538
If you're just looking to open a page in Firefox, all you have to do is this:

Place this in a module / form:

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

Place this where you want to use it:
lRet = ShellExecute(Me.hwnd, "open", "C:\Program Files\mozilla\firefox\firefox.exe", "http://www.userisms.com", vbNullString, 1)

You'll have to change the path to mozilla, I am not sure if I have typed it correctly.
0
 

Author Comment

by:Costellot
ID: 13877229
Thanks for all of your feedback.

Does anyone konw how to obtin the Document Object Model of a Firefox web page page once it has been loaded in the browser?

Thanks,
Tom
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 2000 total points
ID: 13877498
As I mentioned before, you can only do this using the active x control linked above.  The document object model is uses is identical to that of the IE webbrowser object.

Add MozillaControl 1.0 Type Library to your components, then drag a browser window onto your form.  In your form code put:

Option Explicit

Private Sub Form_Load()
    Me.MozillaBrowser1.Navigate "http://www.experts-exchange.com"
   
End Sub

Private Sub MozillaBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If pDisp Is MozillaBrowser1.Object Then
        Debug.Print MozillaBrowser1.Document.Title
   
    End If
End Sub

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question