Error Using iLogic to read data from excel

Error Using iLogic to read data from excel

Mario.van.der.raaf
Enthusiast Enthusiast
367 Views
3 Replies
Message 1 of 4

Error Using iLogic to read data from excel

Mario.van.der.raaf
Enthusiast
Enthusiast

Recently I am having trouble with a script that reads data from an excel file. The file location, permissions or script has not been changed since the last time it has properly worked. This was last friday.

 

The normal workflow involves checking out the excel file from the autodesk vault, checking out the assembly and all underlying components. Reading some values from the excel file / or changing them manually in order to get a different configuration. And then running all other scripts to modify the inventor parts.

 

Last Friday while shutting down windows did an update. The following software was installed:
KB4023057: Update voor Windows Update Service-onderdelen - Microsoft Ondersteuning

 

Right now my way of getting data from excel is returning the following error (my original script is longer but i want to isolate the issue). The filepath and filename have not changed. So this cannot be the issue. Xlsm is also correct since the workbook uses macros. I have also tried the same method of retrieving data but from a different excel file. This results in the same errors.

 

Dim sfile As String = "C:\VaultWorkSpace\Designs\Test\Versis parametric model\Versis input sheet.xlsm"

SharedVariable("Model") = GoExcel.CellValue(sfile, "Input", "B1")

 

Inventor returns the following message when i try to run the script:

 

Error in rule: Test, in document: 000076253.iam

Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)).

 

And under more info:

System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Microsoft.Office.Interop.Excel.ApplicationClass.get_Hwnd()
at Autodesk.iLogic.Core.ExcelInterface.ExcelApplicationWrapper.CreateAndRecordApplication()
at Autodesk.iLogic.Core.ExcelInterface.ExcelApplicationManager.GetApplication()
at iLogic.GoExcel.EnsureApplication()
at iLogic.GoExcel.SetCurrentSheet(String fileName, String sheetName)
at iLogic.GoExcel.SetCurrentSheetNoCache(String bookName, String sheetName)
at iLogic.GoExcel.get_CellValue(String fileName, String sheetName, String cellAddress)
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

My current inventor version is Build: 245, Release: 2021.1 - Date: Tue 07/21/2020

 

Any help would be greatly appreciated.

 

0 Likes
Accepted solutions (2)
368 Views
3 Replies
Replies (3)
Message 2 of 4

SebastianMK
Participant
Participant
Accepted solution

Hi Mario,

 

we have had similar problems when we updated from IV 2018 to 2021 Version. As far as I know Autodesk have changed the Excel Options Defaults in the Past. Please refer to this Post, maybe it helps.

 

New default for iLogic Excel functions in Inventor 2021 - Autodesk Community - Inventor

 

We solved the issue by changing the Excel Options back to COM.

 

Regards

 

Sebastian

 

Message 3 of 4

Mario.van.der.raaf
Enthusiast
Enthusiast

Thank you for the quick reply, when I follow the steps in the link you provided my script can read the values from excel again. (I changed excel options from COM to internal) Luckily I don't do calculations in the sheet based in input from inventor. For people that use that functionality this would still be a problem.

0 Likes
Message 4 of 4

Mario.van.der.raaf
Enthusiast
Enthusiast
Accepted solution

In the end my system administrator could do a repair on the Microsoft office package installed (Microsoft 365 Apps for enterprice - en-us). This allowed for COM as well again. Hope this helps anyone who comes across the same issue.

0 Likes