简体   繁体   中英

Internet Explorer alternative for VBA automation

I have a VBA code to navigate a webpage, read content, click buttons, fill in text etc... This code uses internet explorer. Below I didn't copy the code but only put the main objects I am using to give you an idea:

Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Dim oHTML_Element As IHTMLElement


Set ie = CreateObject("InternetExplorer.Application")
ie.navigate Url
ie.Visible = True

...

Set oBrowser = ie
oBrowser.Visible = True

...    
Set HTMLDoc = oBrowser.document

Set nodeAllDiv = HTMLDoc.getElementsByTagName("p")

Txt = nodeAllDiv.Item(0).innerText

..

HTMLDoc.getElementsByTagName("p").Item(nodeAllDiv.Length - 1).Click

Set listButtons = HTMLDoc.getElementsByTagName("button")
listButtons.Item(0).Click


Set formDivs = HTMLDoc.getElementsByTagName("form")

The issue is that recently the webpage I am navigating is not supported by internet explorer anymore and uses Chrome or Edge, therefore I cannot use this VBA code as it is.

Is there a way I can reuse what I have written so far (reusing the same objects etc... )? If possible without migrating to another framework/language

Thanks

Seleniumbasic is a web automation package for the VBA environment that you might want to take a look at.

Github repo of Seleniumbasic

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM