Why "embedded file" instead of "linked" file ? Because it is easy to manage :
-you have only 1 file : the ipt. If you need to copy, move, rename,... the file, you don't have to know if there is another file to modify too. If you have a linked file, you cannot rename it or the ipt, if the folder is renamed the linked does not function any more, etc. With only 1 file it is much easier.
-each ipt file has its own parameters sheet. If you have a linked file you have to copy and rename the xls file for each ipt file. With an embedded file you don't have to manage this
-all needed information to use the ipt is in the ipt. No links managed by Windows.
-impossible to modify the xls file if you are not in the ipt file. The only person who can modify it is the Inventor user. If you have an external file, evrybody can modify it and so corrupt the ipt.
You do make some good points.
I'm not sure what your end goal is, or why the need to open the file. Does the user need to enter some values into the excel file for parametric reasons?
If so, a work around method would be to use parameters. If there is still a need to have the excel sheet rather than using parameters alone, you can link the parameters to cells in the excel sheet.
Using parameters (either by themselves or connected to a cell in the spreadsheet) you would be able to display the values in a form and have the users edit the form instead, which woul in turn be editting the spreadsheet.
The workaround is :
-create a new file, based on a template containing geometry
-open the xl sheet to choose values. This sheet is very complicated, with links between Excel sheets, Excel search in tables, etc.
-depending of selected values, all neede parameters are sent on a sheet.
-this sheet is red by iLogic with GoExcel... to fill Inventor parameters.
How to open the sheet by iLogic ?
I made an iLogic form, which can launch several rules using buttons. One of this rules should be "Open the parameters sheet".
As I explained a few posts back with some code, if you want to be able to open the excel sheet from within iLogic, you have to research how to "Add Reference" to excel through iLogic.
If you open the VBA Editor (Tools Tab > VBA Editor), click the "Tools" tab again in this screen, and then "References..." you'll access this ability to add references if you were programming directly in the VBA Editor. There should be a library called "Microsoft Excel...... Object Library."
This is what you'd need to add in order to begin using the code I gave (although there is still a little more to the code), but must figure out how to do this and "Add Reference" in iLogic. As I'm not exactly sure how this works.
As a different root, I would suggest switching to programming directly in the VBA Editor, as it makes it much easier to add these references to other libraries. When I was programming my big iLogic program, I wanted to keep everything in iLogic instead of using the VBA Editor... it turned out to be a lot more work than it should have been I believe.
I finally got it to work!
The following code will open the first item embedded in the document (I'm assuming you only have one):
ExcelApp = CreateObject("Excel.Application")
Dim ExcelFile As ReferencedOLEFileDescriptor
ExcelFile = ThisDoc.Document.ReferencedOLEFileDescriptors.Item
Let me know if it helps... Kudos if it works!!!
It works perfectly ! You were right, you need to create the link with Excel, then create an object, then use it. I think the iLogic commands GoExcel... do this automatically.
As you said in your previous message, I think it is easy to make this in VBA instead of iLogic. Basically, iLogic = simple parameterization, VBA = programmation. When you need to use "Dim ..." or "xxx.yyy.zzz... " in iLogic, it's time to switch to VBA !
Subsidiary question : where have you found the syntax ??
I'm glad to hear it worked for you. The object creation for excel I found as part of Curtis' code at the following link:
The rest of the code referencing the embedded file I did through the API. Once you learn how to navigate your way through the API everything becomes a lot easier.
I've just found your code above after searching around for a way to open a linked excel sheet - it's exactly what I was after, cheers.
As a follow up, do you (or anyone else here) know if there's a way to monitor the status of the linked spreadsheet?
Ideally, I'd want to run an iLogic rule when the user saves the spreadsheet.
I've had a look into the API in what look to me to be the relevant areas, but haven't found anything to help - although with little experience in there I think there's a good chance I could be missing something.
In 2014 this worked great. In Inventor 2015, it merges the screen with excel and is unusable. Has anyone seen a way to open an embedded spreadsheet with 2015?
Incase someone else stumble across this, found a way for 2015 to like it.
I changed the last line to: