I need a way to link a single excel sheet to every part/sub assembly in the top assembly using iLogic. I understand the method to replace an existing excel sheet in this case:
changeOK = GoExcel.ChangeSourceOfLinked(partialOldName, newName)
but I'm having trouble doing it when an excel sheet doesn't exist in the first place. I get an error if I set the old name to nothing. I also need to know if iLogic can specify what cell to start in within the excel sheet. Something other than the default A1. Is there a way to do ether of these things?
Hi @AaronJoSmith,
maybe something along the lines of this example?
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim xlApp As Excel.Application = GetObject("", "Excel.Application") Dim xlWorkbook As Excel.Workbook = xlApp.Workbooks.Add() Dim xlWorksheet As Excel.Worksheet = CType(xlWorkbook.Sheets("sheet1"), Excel.Worksheet) sPath = "C:\Temp\" & "Test.xlsx" xlWorksheet.Cells(1, 1) = "Hello world" xlWorksheet.SaveAs(sPath) xlWorkbook.Close() xlApp.Quit() xlApp = Nothing xlWorkbook = Nothing xlWorksheet = Nothing changeOK = GoExcel.ChangeSourceOfLinked(partialOldName, sPath)
Using iLogic, I get an error with this code. Again, the goal is to basically use iLogic to automatically perform the process of clicking "link" in the parameters window, selecting an excel sheet, setting the start cell to, for example B1, and clicking ok. And to do this for every part and assembly within the top assembly which the rule is being run from.
Here is the path to add an excel table to the parameter table using the Inventor API. You can follow the trail back to the document object from link to parameter table here.
Syntax
PartDocument.ComponentDefinition() As PartComponentDefinition
Syntax
PartComponentDefinition.Parameters() As Parameters
Syntax
Parameters.ParameterTables() As ParameterTables
Syntax
ParameterTables.AddExcelTable( ExcelDocument As String, StartCell As String, Link As Boolean ) As ParameterTable
Dim params as Parameters = ThisDoc.Document.ComponentDefinition.Parameters
Dim paramTable as ParameterTable = params.ParameterTables.AddExcelTable("C:UserName\Linked excel.xlsx", "A1", True)
Can't find what you're looking for? Ask the community or share your knowledge.