locked
VBA to Call EDGE Browser RRS feed

  • Question

  • Hi , I found some code , that call IE in Excel VBA, 

    Dim HTMLDoc As HTMLDocument
    Dim oBrowser As InternetExplorer
    Sub Login_2_Website()

    Dim oHTML_Element As IHTMLElement
    Dim sURL As String

    On Error GoTo Err_Clear
    sURL = "https://www.secure website"
    Set oBrowser = New InternetExplorer
    oBrowser.Silent = True
    'oBrowser.timeout = 60
    oBrowser.navigate sURL
    oBrowser.Visible = True

    Do
    ' Wait till the Browser is loaded
    Loop Until oBrowser.readyState = READYSTATE_COMPLETE

    Set HTMLDoc = oBrowser.Document

    HTMLDoc.all.UserName.Value = "twinax"
    HTMLDoc.all.passwd.Value = "123$"

    For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
    If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
    Next

    ' oBrowser.Refresh ' Refresh If Needed
    Err_Clear:
    If Err <> 0 Then
    'Debug.Assert Err = 0
    Err.Clear
    Resume Next
    End If
    End Sub

    Sort of works, it pulls up the website

    So first I would like to use EDGE , thenI jsut want it to put in the user ID , the user needs to put in their password

    thanks for your help

    Thursday, August 27, 2015 2:01 PM

All replies

  • Edge doesn't support a COM interface so using VBA is not possible.  Only IE supports it. 
    • Proposed as answer by Warren Hall Tuesday, August 18, 2020 2:38 AM
    Thursday, August 27, 2015 2:28 PM
  • I see. 

    thanks for the reply

    Can I call EDGE with shell command?

    Thursday, August 27, 2015 2:36 PM
  • I haven't tried it but you should be able to.

    This is a good description of the capabilities of the MS Edge browser.

    Edge Browser

    • Edited by mogulman52 Friday, August 28, 2015 1:22 AM
    Friday, August 28, 2015 1:14 AM
  • After this response was posted, a product called SELENIUM was widely distributed and tested. It creates a competent shell interface for up to five, or more, different browsers that can be selected for use within VBA .

    Begin with https://florentbr.github.io/SeleniumBasic/

    and search on "vba selenium".

    • Edited by Warren Hall Tuesday, August 18, 2020 2:44 AM
    Tuesday, August 18, 2020 2:39 AM
  • I've been using SeleniumBasic since it came out.  It works with Chrome if you update webdriver to match your version of Chrome.  It stopped working with Firefox.  It stopped working with EdgeHTML but now works with Edge Chromium.  Edge Chromium is the new browser based on Google's Chromium open source package. It will replace the legacy version of Edge (EdgeHTML). MS offers a downloadable webdriver like it use to with earlier versions of EdgeHTML. It currently has the EdgeHTML webdriver built into Win 10 which doesn't work with SeleniumBasic. For now you'll have to install Edge Chromium and replace the webdriver in the Selenium install directory ("C:\Users\username\AppData\Local\SeleniumBasic"). You can get webdriver at here . You need to match webdriver to your version of Edge Chromium. The Selenium Edge Chromium drivers are listed on the left.  I tried it on several automated web searching programs and had no problem.


    • Edited by mogulman52 Tuesday, August 18, 2020 12:11 PM
    Tuesday, August 18, 2020 12:08 PM