Hi @MICHAEL.JONES.AMCE. The error message you are showing is very common. It can be confusing getting a reference to the main application object of a different application other than the one you are actively working within. Some ways seem to work OK for some folks most of the time, and for others only sometimes, while not working at all for yet others. The 'ApplicationClass' type appears to be for 'internal use only', so I generally do not recommend relying on that one. But then the regular Application object appears to be an Interface type, instead of a Class type, so you can not use the 'New' keyword to create a new instance of one. However, we can set a variable to represent an Interface type, then set its value another way, usually through some sort of 'Cast' routine. Below is another pretty simple routine I have just for getting a reference to an instance of the Excel Application object. This routine uses a Try...Catch statement while it first attempts to get an already running instance, then if that fails, it tries to create an instance, and casting the object it gets to the Interface type variable. You can incorporate something like this into your 'Excel' resources. I also have some that are much more detailed for getting or creating things like a Workbook or a Worksheet, with several inputs and optional inputs.
Imports Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop
AddReference "Microsoft.Office.Interop.Excel.dll"
Sub Main
Dim oExcel As Microsoft.Office.Interop.Excel.Application = GetExcel(True)
Dim oWB As Microsoft.Office.Interop.Excel.Workbook = Nothing
Dim oWS As Microsoft.Office.Interop.Excel.Worksheet = Nothing
If oExcel IsNot Nothing Then
Logger.Info("Got a reference to an Excel Application instance.")
oWB = oExcel.ActiveWorkbook
oWS = oExcel.ActiveSheet
If oWB IsNot Nothing Then
Logger.Info("Excel Active Workbook Name = " & oWB.Name)
oWB = Nothing
Else
Logger.Info("No Active Workbook.")
End If
If oWS IsNot Nothing Then
Logger.Info("Excel Active Worksheet Name = " & oWS.Name)
oWS = Nothing
Else
Logger.Info("No Active Worksheet.")
End If
Else
Logger.Debug("No instance of Excel Application obtained!")
End If
oExcel = Nothing
End Sub
Function GetExcel(Optional bVisible As Boolean = False) As Excel.Application
Dim oXL As Microsoft.Office.Interop.Excel.Application
Dim oObj As Object = Nothing
Try
'try to find an already running instance of the Excel Application
oObj = GetObject(, "Excel.Application")
oXL = TryCast(oObj, Microsoft.Office.Interop.Excel.Application)
Catch
'it wasn't found open, so create an instance of it (start the application)
oObj = CreateObject("Excel.Application")
oXL = TryCast(oObj, Microsoft.Office.Interop.Excel.Application)
End Try
oObj = Nothing
If oXL IsNot Nothing Then oXL.Visible = bVisible
Return oXL
End Function
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)