I'm new to Excel macro. I have a macro which was given to me by an ex-teammate who has left the team many years already. When the macro runs, it invokes IE, opens a page, and then automate data-entry and mouse-clicks.
Now that IE will become unsupported. We have to use Edge. How can I convert this macro so that it will invoke Edge and do the same automation thing on Edge?
I searched on many web community and most seems to tell me that I need Selenium. Problem is that I cannot install Selenium due to my company's policy.
Of all the suggestions I could find on web community, I found this one seems to be addressing my problem : Automating Edge Browser using VBA without downloading Selenium
I followed exactly the suggestion and installed the registry :
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Main] "NotifyDisableIEOptions"=dword:00000002
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Main\EnterpriseMode] "EnableGlobalWindowListInIEMode"=dword:00000001
After that, the IE on my machine is disabled, and I can no longer see it on the Windows START menu.
Then, I tried to run my macro again but it is still invoking IE.
Is there any expert here who can give me some advice so that my macro will run on Edge and the code can also run on Edge ?
I'm really new to macro. Appreciate if any expert here can point out to me exactly which line of code I need to change and how to change. Thanks a ton !
This is excerpt of my macro [masked a little to hide sensitive info]
Dim Element As HTMLButtonElement
Dim IE As InternetExplorer, URL as String, HTMLDoc as HTMLDocument
Dim value_element as String
.
.
.
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate "https://example.com"
Do While IE.Busy or IE.readState <> READYSTATE_COMPLETE: DoEvents: Loop
If Instr(IE.Document.body.innerText, "There is a problem with this website's security certificate.") >0 Then
IE.Document.links(1).click
Do While IE.Busy or IE.readState <> READYSTATE_COMPLETE: DoEvents: Loop
End If
Set HTMLDoc = IE.Document
HTMLDoc.getElementById("ElementA").Value = value_element
For Each Element in HTMLDoc.getElementsByTagName("Input")
If Element.Value = "Submit" Then
Call Element.click
Do While IE.Busy or IE.readState <> READYSTATE_COMPLETE: DoEvents: Loop
Exit For
End If
Next Element