Set Invokepattern problem = Button.Getcurrentpattern(Uia_invokepatternid)

Asked

Viewed 185 times

1

I have a problem with the save button on IE11 - I changed the field to the language of the program (Portuguese).

Sub DownloadFile(h As Long)
Dim o As IUIAutomation
Dim e As IUIAutomationElement
Dim iCnd As IUIAutomationCondition
Dim Button As IUIAutomationElement
Dim InvokePattern As IUIAutomationInvokePattern

Set o = New CUIAutomation
h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)
If h = 0 Then Exit Sub

Set e = o.ElementFromHandle(ByVal h)
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Salvar")
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
*Set InvokePattern = Button.GetCurrentPattern(UIA_InvokePatternId)*
InvokePattern.Invoke
End Sub

The mistake you’re making:

Run-time error '91': Object variable or with block variable not set

  • On which line does this error occur? And you are declaring the Win function: FindWindowEx?

  • Error is on line: Set Invokepattern = Button.Getcurrentpattern(Uia_invokepatternid) The statement at the beginning: Declare Ptrsafe Function Findwindow Lib "user32" Alias "Findwindowa" (Byval lpClassName As String, Byval lpWindowName As String) As Long

  • @danieltakeshi can help me?

  • One problem that may occur is the of this answer. In which the download window can lock when opening in IE and a third-party program should be used. You have the code to open the download window or the download link?

  • See also this answer file download

  • I will put the code on the link: https://answall.com/questions/308187/problema-set-invokepattern-button-getcurrentpatternuia-invokernid-vba - I believe you are saying yes.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.