Reputation: 21
I have a macro that opens Excel from Solidworks to pull part information from a table. Recently I'm getting this error when it hits the line "set xlApp = New Excel.Application"
The error is Run-time error '-2147023728 (80070490)': Element not found.
I don't have any missing libraries, and I'm using excel.exe as my reference. (ver 16) I get this same error if I try to run this simplified code from Outlook instead of Solidworks.
Dim xlApp As Object
Sub main()
Set xlApp = New Excel.Application
End Sub
Other variants of code I've tried:
Dim xlApp As Excel.Application
Sub main()
Set xlApp = GetObject(, "Excel.Application")
End Sub
Result: Run-time error '429': ActiveX component can't create object.
If change this to:
Set xlApp = new Excel.Application
like I have in the previous example then I get the Element not found error. So, late-binding vs. early-binding has no effect.
This is all being tested with excel already running. VBA code inside Excel works fine unless I use that specific line. I can use "Application.ActiveWorkbook" inside Excel without error and without defining Application (because it's already Excel).
I have removed and reinstalled Office to no avail. Researching hasn't directed me to anything similar for other solutions to try.
Thanks in advance. -Taylor
Upvotes: 2
Views: 1336
Reputation: 1
I have the same problem few days ago. Already applied many ways but not fixed that problem. Finally, I accidentally recognized that problem caused by user's permission. The problem was solved when I run it under administrative role. Hope that helps.
Upvotes: 0
Reputation: 116
I've run into this issue on some machines I support. Here was my solution, late binding was the answer for me.
Dim xlApp As Object
Sub main()
Set xlApp = CreateObject("Excel.Application")
xlApp.Application.Visible = True
'This line would create a blank workbook, but you could open an existing one here
'xlApp.Workbooks.Add
End Sub
From there you could open the workbook you need and continue as normal.
Upvotes: 0