Having trouble reading values from Excel spreadsheet

Having trouble reading values from Excel spreadsheet

hartmant
Participant Participant
1,298 Views
9 Replies
Message 1 of 10

Having trouble reading values from Excel spreadsheet

hartmant
Participant
Participant

Hey Guys,

 

I am new to the iLogic side of inventor but want to learn it to help make my work more efficient. I've been doing some research and working through some tutorials form Autodesk University and some other examples I've found on youtube. I am currently trying to use iLogic to pull parameter values from and excel spread sheet. I'm having a lot of trouble with the command GoExcel.CellValue. Every time I run that command it gives me an error message. I have included screen shots of the error message and the code I am trying to use.  In the test code, I simply trying to set the plate_width parameter value equal to the value of cell in the the spreadsheet. I've double checked the spelling of the file names, file locations, and cell location. Have any of you experienced this? I can't figure it out. Thanks in advance for any help. 

error message more info.PNGError message.PNGsample code.PNG

0 Likes
Accepted solutions (1)
1,299 Views
9 Replies
Replies (9)
Message 2 of 10

thomas.fitzgerald
Alumni
Alumni

Hi @hartmant

 

The error indicates a COM object error with Excel.  The code looks like it should work, so I'm thinking it is something with your version of Excel relative to the version of Inventor you are using.  Can you indicate which version of Inventor and Office you are using?

Thomas Fitzgerald

Principal Implementation Consultant
0 Likes
Message 3 of 10

hartmant
Participant
Participant

Thomas,

 

Thank you for your reply. Yes, I am running Inventor professional 2020 and Excel version 2004 (Build 12730.20250)

0 Likes
Message 4 of 10

thomas.fitzgerald
Alumni
Alumni

Ok, I see the problem.  Your office version uses the .xls file extension for Excel.  In your code, you have .xlsx.   Try changing the file extension and see what happens.

Thomas Fitzgerald

Principal Implementation Consultant
0 Likes
Message 5 of 10

hartmant
Participant
Participant

I tried and the same error occurs. I checked the file properties and it shows the file type as .xlsx file. I've included a screen shot of the properties screen and the excel document. 

0 Likes
Message 6 of 10

thomas.fitzgerald
Alumni
Alumni

Ok, the other thing I'm seeing is the first line of your code you are accessing the excel spreadsheet by full document name and path.  Try deleting the first line of code and just use the second.

 

 

Thomas Fitzgerald

Principal Implementation Consultant
0 Likes
Message 7 of 10

hartmant
Participant
Participant

I just tried and experienced the same error. I have included a screen shot of the code just to make sure it is right. 

running only second line of code.PNG

0 Likes
Message 8 of 10

thomas.fitzgerald
Alumni
Alumni

I tried it using the code below without any error:

 

	Dim xlPath As String = "C:\Users\Thomas\Documents\Inventor\automation practice\parameter test.xlsx"
	plate_length = GoExcel.CellValue(xlPath, "Sheet1", "A2")

 

Thomas Fitzgerald

Principal Implementation Consultant
0 Likes
Message 9 of 10

johnsonshiue
Community Manager
Community Manager
Accepted solution

Hi Guys,

 

Excel 2004 may not be supported by Inventor 2020. See the system requirements for 2020.

 

https://knowledge.autodesk.com/support/inventor/learn-explore/caas/sfdcarticles/sfdcarticles/System-...

 

You may need to upgrade Excel.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 10 of 10

hartmant
Participant
Participant

Yes, that is what the problem was. I spoke to Thomas Fitzgerald on the phone as well we confirmed this was the problem. I updated my Office 365 to the newest version and now the code works as it should. Thank you both for your help!