- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
OK. I was testing using Inventor 2022.1.1 (finally got updated from 2021 this week!) and a local iLogic rule. Here is the rule I used.
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oExcelFile As String = "C:\Temp\Exported Custom Tables.xlsx"
oFormat = FileFormatEnum.kMicrosoftExcelFormat
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("TableName", "")
'oOptions.Add("ExportedColumns","Part Number;Quantity;Description")
oOptions.Add("IncludeTitle", True)
oOptions.Add("StartingCell", "A1")
'oOptions.Add("Template", "C:\Temp\Exported CTables Template.xlsx")
oOptions.Add("AutoFitColumnWidth", True)
If oSheet.CustomTables.Count = 0 Then Exit Sub
Dim i As Integer = 1
For Each oCTable As CustomTable In oSheet.CustomTables
oTableName = "Table Name" & i.ToString
oOptions.Value("TableName") = oTableName
Try
oCTable.Export(oExcelFile, oFormat, oOptions)
Catch oEx As Exception
MsgBox("The Export method failed." & vbCrLf & oEx.Message & vbCrLf & oEx.StackTrace, , "")
End Try
i = i + 1
Next
Short, and to the point, just for testing. The result is one tab in the Excel file, tab named "Table Name 2", data from 2nd table is showing on that sheet. I know it also wrote the data from the first table to it first, then overwrote it all with the data from the second table. Now I have another sneaking suspicion in the back of my mind about this situation. By default, when I start Excel, a new Workbook only has one tab/sheet. I'm wandering if I changed that to always include at least 2 tabs/sheets, would the method then use the second tab/sheet, if it were available?
Wesley Crihfield
(Not an Autodesk Employee)