-
May 19th, 2019, 06:08 PM
#1
Thread Starter
Addicted Member
how to open mozilla firefox using this code
I found some code in http://planet-source-code.com
and run good
but when run project and click command button open IE. I want open mozilla firefox and run good how can this
code here
form1
Dim captIE As New SHDocVw.InternetExplorer
Dim captieclass As New Class1
Private Sub Command1_Click()
captIE.Visible = True
captIE.Navigate Text1.Text
End Sub
Private Sub Form_Load()
Set captieclass.captx = captIE
End Sub
class1
Public WithEvents captx As SHDocVw.InternetExplorer
Private Sub captx_StatusTextChange(ByVal Text As String)
Form1.Text1.Text = Text
Form1.List1.AddItem Now & " - " & Text
End Sub
-
May 19th, 2019, 10:52 PM
#2
Lively Member
Re: how to open mozilla firefox using this code
Wouldn't it be easier just to use:
Code:
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
Sub OpenFirefox
lRet = ShellExecute(Me.hwnd, "open", "C:\Program Files\Mozilla Firefox\firefox.exe", "http://www.vbforums.com", vbNullString, 1)
End Sub
Last edited by MikeSW17; May 19th, 2019 at 11:00 PM.
-
May 22nd, 2019, 01:24 PM
#3
Thread Starter
Addicted Member
Re: how to open mozilla firefox using this code
-
May 23rd, 2019, 05:08 AM
#4
Re: how to open mozilla firefox using this code
there is not current com object for firefox, so not possible in vb6
have you looked at sellenium?
can supposedly automate any browser by code
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 23rd, 2019, 05:15 AM
#5
Re: how to open mozilla firefox using this code
Code:
Dim captIE As New SHDocVw.InternetExplorer
If you make a reference to InternetExplorer then ofcourse it will Internet Explorer and not any other tool.
If you want to start FireFox then you need to find to location of the FireFox executable and start the application using the Shell command.
-
Apr 19th, 2020, 12:22 PM
#6
Thread Starter
Addicted Member
Re: how to open mozilla firefox using this code
Originally Posted by MikeSW17
Wouldn't it be easier just to use:
Code:
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
Sub OpenFirefox
lRet = ShellExecute(Me.hwnd, "open", "C:\Program Files\Mozilla Firefox\firefox.exe", "http://www.vbforums.com", vbNullString, 1)
End Sub
How will it be used in this script please guide me
-
Apr 20th, 2020, 10:02 PM
#7
Thread Starter
Addicted Member
Re: how to open mozilla firefox using this code
-
Apr 20th, 2020, 11:47 PM
#8
Re: how to open mozilla firefox using this code
Originally Posted by kako0000000
any one tell me
You may not be being clear (OR complete enough) with your request ?
What I am about to post is similar to a post(s) above, but I will post it anyway, in case it helps.
I am old with a blurry memory.
I recalled creating something for an elderly neighbor, which launched Firefox for him.
I found that code and trimmed the heck out of it.
We were both using XP at the time, but I just tried 'his' program in Win 8.1 32 bit, and it still worked.
If you are using 64bit and/or different Windows version you may have to tweak the code to reflect the correct path
Code:
Option Explicit
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
Private Sub Command1_Click()
Dim sProgram As String
sProgram = "C:\Program Files\Mozilla Firefox\firefox.exe"
LaunchProgram sProgram
End Sub
Private Sub LaunchProgram(sFilename As String)
Dim retval As Long
Dim LAction As String
LAction = "Open"
retval = ShellExecute(0&, _
LAction, _
sFilename, _
vbNullString, _
vbNullString, _
WindowState)
End Sub
HTH,
Rob
Last edited by Bobbles; Apr 20th, 2020 at 11:52 PM.
-
Apr 21st, 2020, 09:16 PM
#9
Thread Starter
Addicted Member
Re: how to open mozilla firefox using this code
Bobbles brother,
Looks like you didn't read my post properly.
I want to ask,
When I open the web, it shows me all the links that it will open.
The script I sent works fine, but it does open only Internet Explorer.
I want open mozilla firefox
-
Apr 21st, 2020, 09:49 PM
#10
Re: how to open mozilla firefox using this code
see post #4. You can not interact with firefox from VB6 the way you can with IE.
-
Apr 22nd, 2020, 06:52 AM
#11
Re: how to open mozilla firefox using this code
in case you do not understand what has been posted before
there is currently no native vb6 or com objects that can be used to automate any browsers, except internet explorer
shell execute will not do what you want, it will only start the firefox or other browser program, but will give you no control over it
shell execute is ideal if you just want to open a webpage in the default browser, without knowing which browser the user has as default
basically you can not do what you want
unless you research sellenium to see if it can work from vb6 as required
there is a reasonably active forum on the sellenium site
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|