Results 1 to 11 of 11

Thread: how to open mozilla firefox using this code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    183

    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

  2. #2
    Lively Member
    Join Date
    May 2017
    Posts
    81

    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    183

    Re: how to open mozilla firefox using this code

    any tell

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,906

    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.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    183

    Re: how to open mozilla firefox using this code

    Quote Originally Posted by MikeSW17 View Post
    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

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    183

    Re: how to open mozilla firefox using this code

    any one tell me

  8. #8
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: how to open mozilla firefox using this code

    Quote Originally Posted by kako0000000 View Post
    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.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    183

    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

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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.

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
  •  



Click Here to Expand Forum to Full Width