ilogic and excel

ilogic and excel

Anonymous
Not applicable
1,764 Views
13 Replies
Message 1 of 14

ilogic and excel

Anonymous
Not applicable

I have and ilogic rule that reads an excel file. On one machine with an external hard drive, file path ("E:\xxx") there is no problem. On another machine reading from the server, file path ("E:\xxx") I get the following error:

 

System.Runtime.InteropServices.COMException (0x80030002):  could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND))

   at Microsoft.Office.Interop.Excel.ApplicationClass.get_LanguageSettings()

   at iLogic.GoExcel.ExcelAppGetLanguageID(Application app)

   at iLogic.GoExcel.SetCurrentSheet(String fileName, String sheetName)

   at iLogic.GoExcel.FindRow(String fileName, String sheetName, Object[] sizeArgs)

   at LmiRuleScript.Main()

   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Can someone explain why?

0 Likes
1,765 Views
13 Replies
Replies (13)
Message 2 of 14

philippe.leefsma
Alumni
Alumni

Hi

 

Can you post the iLogic code, maybe it will give more clue? Did you determine what is the iLogic call that is problematic?

 

Did you try with VBA directly? You could determine if it is iLogic related or more general.

 

Another thing you could try is re-installing Excel on the machine that has the issue.

 

Here is a VBA sample you can run from Inventor (you need to add a reference to Microsoft Excel Object Lib):

 

Sub TestOpenXls()

    Dim xlsApp As Excel.Application
    Set xlsApp = CreateObject("Excel.Application")
    xlsApp.Visible = True

    Dim wb As Excel.workbook
    Set wb = xlsApp.Workbooks.Open("X:\TEMP\adn.xlsx")
    
End Sub

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 14

liminma8458
Collaborator
Collaborator

I got similar problem. How can you solve the last problem.

 

my problem is like that: I run iLogic under Inventor 2016 and Excel 2013. All other machine run well except one machine have such error:

 

System.Runtime.InteropServices.COMException (0x8002801D): Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

   at Microsoft.Office.Interop.Excel._Application.get_LanguageSettings()

   at iLogic.GoExcel.SetCurrentSheet(String fileName, String sheetName)

   at iLogic.GoExcel.get_CellValue(String fileName, String sheetName, String cellAddress)

   at LmiRuleScript.Main()

   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Look like problem comes from "GoExcel.CellValue()". I can even open the Excel in iLogic without problem.

 

Attached is my code and error message.

 

Thanks for your help.

 

Limin

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

Message 4 of 14

Owner2229
Advisor
Advisor

Hi, does the path to the Excel file vary for each computer?

 

You can try the code below:

 

---Start of iLocic code---

Dim oExcel As Object
Dim oWB As Object
Dim oWS As Object
Dim ExcelFile As String
oExcel = CreateObject("Excel.Application")
'Set your Excel document here: oWB = oExcel.Workbooks.Open("E:\cc_data.xls") oExcel.Visible = False oExcel.DisplayAlerts = False oWS = oWB.Sheets(1) oWB.Activate 'First is row, then column: oWS.Cells(1, 1).Value = "Test" oWB.Close (True) oExcel.Quit

---End of iLocic code---

 

Or the same in VBA ( no need for adding a reference to Microsoft Excel Object Lib. It even causes problems if someone has different version of Excel).

 

---Start of VBA code---

Dim oExcel As Object
Dim oWB As Object
Dim oWS As Object
Dim ExcelFile As String
Set oExcel = CreateObject("Excel.Application")
'Set your Excel document here: Set oWB = oExcel.Workbooks.Open("E:\cc_data.xls") oExcel.Visible = False oExcel.DisplayAlerts = False Set oWS = oWB.Sheets(1) oWB.Activate 'First is row, then column: oWS.Cells(1, 1).Value = "Test" oWB.Close True oExcel.Quit

---End of VBA code---

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 5 of 14

liminma8458
Collaborator
Collaborator

I use "GoExcel.open("cc_data.xls"). It did open the file. But the following "GoExcel.CellValue()" does not work. 

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 6 of 14

Owner2229
Advisor
Advisor

I know, but since it is not working for you now, we're suggesting you another way of doing this.

Just try it.

 

Btw. This is how the GoExcel.Value comand should look like:

 

GoExcel.CellValue("A1") = "Test"

Or:

 

Dim row As Integer
row = 1
GoExcel.CellValue("A" & row) = "Test"  

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 7 of 14

liminma8458
Collaborator
Collaborator

very basic one:

 

icross_bar_dia=GoExcel.CellValue("cc_data.xls", "Sheet1", "cross_bar_dia")
icross_bar_lgth=GoExcel.CellValue("cc_data.xls", "Sheet1", "cross_bar_lgth")

 

see attached

 

Thank you so much!

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 8 of 14

Owner2229
Advisor
Advisor

In the CellValue you have to specify the cell, not the file, nor sheet and not even whatever is the third.

You should have the GoExcel opening on first line so it should look like below. I dont know in which cells you have the data, so you have to modify this.

The "cc_data.xls" part must reffer full path to the document so it will be something like "C:\WhatEverPath\cc_data.xls".

Uncomment the "GoExcel.Save" if you're writing something in the file, so it will save.

 

GoExcel.Open("cc_data.xls", "Sheet1")

icross_bar_dia = GoExcel.CellValue("A1")
icross_bar_lgth = GoExcel.CellValue("B1")

'GoExcel.Save
GoExcel.Close
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 9 of 14

liminma8458
Collaborator
Collaborator

The third parameter is the cell name in Excel file.

 

I have the codes exactly on other machines which also run Inventor 2016 and Excel 2013. All of other machines work fine except one.

 

So I am very puzzle.

 

 

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 10 of 14

Owner2229
Advisor
Advisor

There may be an error in your code that didnt reveal on the other PCs. So you should try the codes above ^^.

Do you have instaled the same service packs on all the PCs?

 

Try this code and let me know if it works:

GoExcel.Open("C:\SetYourPathHere\cc_data.xls", "Sheet1")
icross_bar_dia = GoExcel.CellValue("cross_bar_dia")
icross_bar_lgth = GoExcel.CellValue("cross_bar_lgth")
MsgBox("Dia: " & icross_bar_dia & vblf & "Lgth: " & icross_bar_lgth)
GoExcel.Close

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 11 of 14

Tony_Yates
Advocate
Advocate

Hi 

Did you ever resolve this issue?

 

We have now got the same problem on one out of 5 machines. Only recently happened it was working fine last week.

The machines that work ok are running inventor 2019 and excel 2016. The one that stopped working had inventor 2019 and excel 2010, we upgraded the excel to 2016 but didn't make a difference.

 

Hope you can help.

0 Likes
Message 12 of 14

liminma8458
Collaborator
Collaborator

Hi,

I don't remember how I resolved the problem exactly. But we don't use .open or .close syntaxs finally.

Try to set up a system variable UseLibXL as follow to see whether it solves your problem. It should also make you iLogic run faster.

https://forums.autodesk.com/t5/inventor-customization/ilogic-run-much-longer-in-windows-10-and-multi...

Good luck

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 13 of 14

Tony_Yates
Advocate
Advocate

Uninstalled "foxit" now working fine.

0 Likes
Message 14 of 14

liminma8458
Collaborator
Collaborator

Yes. You remind that. The "Foxit" indeed ever caused the problem to us. Maybe it automatically puts some plugin in the excel.

Glad to hear you solved the problem

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes