Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I'm navigating IE via VBA to reach a web site and download a file. No problem about navigating the site, neverthless I can't interact with the popup “Do you want to open this file?” (I use IE9).
So, I've tried to travel the API road for the first time in my life in order so save the file, but unsuccessfully.
My attempt (in the same module):
Then the code to navigate the site.
The error is in the following line (error 404 vba object required)
Available Library;
Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library
Microsoft HTML Object Library
Microsoft Forms 2.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Internet Controls
Microsoft VBScript Regulare Expressions 5.5
Microsoft Visual Basic for Application Extensibility 5.3
UIAutomationClient
I'm navigating IE via VBA to reach a web site and download a file. No problem about navigating the site, neverthless I can't interact with the popup “Do you want to open this file?” (I use IE9).
So, I've tried to travel the API road for the first time in my life in order so save the file, but unsuccessfully.
My attempt (in the same module):
Code:
Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hwndParent As Long, _
ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long
Code:
sub navigate ()
'no problem in navigating the site and click on download file'
'then the attempt of managing the popup'
Dim o As IUIAutomation
Dim e As IUIAutomationElement
Set o = New CUIAutomation
Dim h As Long
h = ieApp.Hwnd
h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)
If h = 0 Then Exit Sub
Set e = o.ElementFromHandle(ByVal h)
Dim iCnd As IUIAutomationCondition
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")
Dim Button As IUIAutomationElement
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
Dim InvokePattern As IUIAutomationInvokePattern
Set InvokePattern = Button.GetCurrentPattern(UIA_InvokePatternId)
InvokePattern.Invoke
The error is in the following line (error 404 vba object required)
Code:
h = ieApp.Hwnd
Available Library;
Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library
Microsoft HTML Object Library
Microsoft Forms 2.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Internet Controls
Microsoft VBScript Regulare Expressions 5.5
Microsoft Visual Basic for Application Extensibility 5.3
UIAutomationClient