Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic To Create Excel Sheet link When One Doesn't exist

4 REPLIES 4
Reply
Message 1 of 5
AaronJoSmith
300 Views, 4 Replies

iLogic To Create Excel Sheet link When One Doesn't exist

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?

4 REPLIES 4
Message 2 of 5

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)

 

Message 3 of 5
AaronJoSmith
in reply to: AaronJoSmith

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.

Message 4 of 5

Thanks in advance.

Message 5 of 5
A.Acheson
in reply to: AaronJoSmith

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.AddExcelTableExcelDocument 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)

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report