If I open Excel via double clicking on an Excel file then use VBA to open up MyExcelFile and run MyMacro, things go fine. But if I use VBA to create a new instance of Excel using CreateObject, and use VBA to open up MyExcelFile and run MyMacro, a third-party Add-In I don't have control over behaves differently (wrong).
I'm wondering if there are settings for Excel instances I can control and should set explicitly? I got really excited when I saw this, but it didn't solve my problem: "New" Excel.Application vs Excel.Application
Does opening Excel via point-and-click initiate different settings from CreateObject("Excel.Application")? Maybe different working directories or something?
In summary, for my third-party AddIn:
Works:
Workbooks.Open("MyExcelFile")
Application.Run "MyExcelFile!MyMacro"
Does not work:
Dim ObjXL
Set objXL = CreateObject("Excel.Application")
objXL.Workbooks.Open("MyExcelFile")
objXL.Application.Run "MyExcelFile!MyMacro"
Within MyMacro, I load the AddIn:
Dim success as Boolean
...
success = False
success = Application.RegisterXLL("PathToAddIn_x64.xll")
If Not (success) Then
Exit Sub
End If
success = Application.RegisterXLL("PathToOtherAddIn_x64.xll")
If Not (success) Then
Exit Sub
End If