0

I have use this code

Controlling IE11 "Do you want to Open/Save" dialogue window buttons in VBA

But I get the error

"user defined type not defined"

on

Dim o As IUIAutomation

Someone knows how can I fix it?

Community
  • 1
  • 1
Eli
  • 65
  • 5

2 Answers2

1

I guess you have to add a project reference to the UI Automation library. At least I could reproduce your error and fix it by adding the reference.

UI Automation Client

DAXaholic
  • 31,036
  • 5
  • 72
  • 73
0

Add it using code

Public Sub AddReference()

ThisWorkbook.VBProject.References.AddFromFile 
"C:\Windows\System32\UIAutomationCore.dll"

End Sub

and goto excel>>option>>Trust Center>>Trust Center Setting>>Macro setting and check on the Trust access to the VBA project object model

Aurasphere
  • 3,631
  • 12
  • 42
  • 69