So I've success navigated to a website, clicked the download icon button, and successfully clicked the "Save" and "Open" popup dialogue in IE11 to open a .CSV file in Excel.
The problem is that if I add even a single line of code after that, with the exception of msgbox, the Excel file just won't open.
I've tried all of the following in Excel VBA to no avail:
DoEvents, Application.Wait, Application.Visible = True, Application.ScreenUpdating = True, TimeDelay subroutine that uses Timer, Application.EnableEvents = True
Set iuiAutoCore = New CUIAutomation
lWindowNum = ieApp.HWND
'Call MsgBox(Hex(lWindowNum))
lWindowNum = FindWindowEx(lWindowNum, 0, "Frame Notification Bar", "")
'Call MsgBox(Hex(lWindowNum))
If lWindowNum = 0 Then: Exit Sub
SetForegroundWindow (lWindowNum)
' Click Save
Set iuiAutoCondition = iuiAutoCore.CreatePropertyCondition(ByVal UIA_NamePropertyId, "Save")
Set iuiButton = iuiAutoCore.ElementFromHandle(ByVal lWindowNum).FindFirst(TreeScope_Subtree, iuiAutoCondition)
Set iuiInvokePattern = iuiButton.GetCurrentPattern(UIA_InvokePatternId)
iuiInvokePattern.Invoke
TimeDelay (1)
' Click Open
Set iuiAutoCondition = iuiAutoCore.CreatePropertyCondition(ByVal UIA_NamePropertyId, "Open")
Set iuiButton = iuiAutoCore.ElementFromHandle(ByVal lWindowNum).FindFirst(TreeScope_Subtree, iuiAutoCondition)
Set iuiInvokePattern = iuiButton.GetCurrentPattern(UIA_InvokePatternId)
iuiInvokePattern.Invoke
' Cannot add any more code after this, otherwise the downloaded Excel spreadsheet will not open
I expect the IE11's download dialog box's "Save" and "Open" to be clicked, and a .CSV to be opened in Excel, which does happen.
However, I cannot add any more lines of code after that, otherwise Excel won't open.