You can also use UI Automation to close Edge window.
'* Add a Reference to the UIAutomationClient Library(UIAutomationCore.dll) Public Sub CloseEdgeWindow() Dim uiAuto As CUIAutomation Set uiAuto = New CUIAutomation Dim elmRoot As IUIAutomationElement Set elmRoot = uiAuto.GetRootElement Dim cndChromeWidgetWindows As IUIAutomationCondition Set cndChromeWidgetWindows = uiAuto.CreatePropertyCondition( _ UIA_ClassNamePropertyId, _ "Chrome_WidgetWin_1" _ ) Dim aryChromeWidgetWindows As IUIAutomationElementArray Set aryChromeWidgetWindows = elmRoot.FindAll(TreeScope_Children, cndChromeWidgetWindows) Dim wptn As IUIAutomationWindowPattern, i As Integer For i = 0 To aryChromeWidgetWindows.Length - 1 If aryChromeWidgetWindows.GetElement(i).CurrentName Like "*- Microsoft" & ChrW(&H200B) & " Edge" Then Set wptn = aryChromeWidgetWindows.GetElement(i).GetCurrentPattern(UIA_WindowPatternId) wptn.Close End If Next End Sub
Microsoft Edge is not support the COM automation like IE.
For automation scenarios, you can use the WebDriver.
Yes, as you mentioned, the WebDriver like Selenium Basic could be fine if install is allowed. Many PC controlled under company unfortunately are not around me, at least though.
So, I am looking for VBA that directly codes on Edge or Chrome browser.
The translation tool from for IE into Edge or Chrome would be great but still I cannot find it.
kinuasa-san's code to close edge window is great for me. Thank to it, a VBA I used via IE was able to convert them via Edge smoothly. I don't imagine that just one line code is fine in IE. But still just only one VBA I ever code is converted.
Anyway thanks your hints, thanks your time, thanks your advise.