VBA automation with Edge IE mode

J710 11 Reputation points
2022-04-28T01:47:11.177+00:00

I have been using VBA to automate IE in the past and I understand that IE with be demised soon. I heard that ActiveX can be used in Edge IE mode until 2029. May I know how can I do so? Do I have to change any of my old code? My code which worked with IE will only open IE browser and will not interact with Edge IE mode. Do I have to amend anything to tell VBA to interact with Edge IE mode instead of IE? My computer is in Win10 20H2 and KB5011487 have been installed to it.

My code is something like this:
‘opened the XXXX website manually before running the code
‘Search for tab named XXXX
Set ieApp = FindIEObject(“XXXXX”)
‘Send the text to the yyy text box
ieApp.document.all.Item(“yyy”).Value = ThisWorkbook.Sheets(“Sheet1”).Range(“A” & 1)
‘Press click
ieApp.document.getElementById(“zzz”).Click

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,174 questions
{count} votes

8 answers

Sort by: Most helpful
  1. Roger Scorefun 1 Reputation point
    2022-06-11T17:08:26.47+00:00

    Kelvin, your Code is wonderful and works fine - many thanks

    I'm now able to read the rows of a html-table including download-links for pdf-files (as it works earlier with IE webbrowser-control)
    but it doesn't work to download the files using URLDownloadToFile

    It's a webpage where I'm logged in with username and password

    Any idea?
    Many thanks for reading
    Regards Roger

    0 comments No comments

  2. Naser 1 Reputation point
    2022-10-12T08:47:29.443+00:00

    `Public Declare PtrSafe Function findEdgeDOM Lib "user32" (Title As String, URL As String) As HTMLDocument

     'Find criteria-hitting Edge page in IE mode  
      
     Dim hwndIES As Long  
                  
     Do  
          
         hwndIES = enumHwndIES  
                      
         If hwndIES Then  
              
             Set findEdgeDOM = getHTMLDocumentFromIES(hwndIES)  
             If Not findEdgeDOM Is Nothing Then  
                  
                 If InStr(findEdgeDOM.Title, Title) * InStr(findEdgeDOM.URL, URL) Then  
                  
                     Do  
                      
                         hwndIES = enumHwndIES  
                          
                     Loop While hwndIES  
                  
                     Exit Function  
                      
                 Else  
                  
                     Set findEdgeDOM = Nothing  
                      
                 End If  
             End If  
                  
         End If  
          
     Loop While hwndIES  
          
    

    End Function`

    In this part I have error "do" Compile error: "Invalid Outside procedure"

    Any advise

    Thank you


  3. Kirk Cantrell 0 Reputation points
    2023-03-21T15:47:08.3+00:00

    @AHRION GALLEGOS

    if you can, will you please come back around to about posting MS-Edge/HTMLDocument automation? Sounds like useful stuff!

    0 comments No comments