- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I am having one little issue with one line of code. Here is my setup:
I have a drawing file that has multiple drawing sheets in the drawing file. Each sheet has a BOM and i need to pull all of the BOM'S off of each sheet and export them to excel. The number of sheets will vary in each drawing file i make. Every thing works but my program is hanging when i try to pull the name of the sheet in the drawing file. I am trying to take the name of the sheet and export that name to excel and put the sheet name on the tab name in excel. Now the names of the sheets will change between each drawing file.
Here is my line of code that i am having problems with:
'specify the XLS tab name
'here the file name is used
oOptions.Value("TableName") = ActiveSheet.sheet.name(False) 'without extension
Here is the drawing file
Here is the tabs in the excel
Here is the dwg file here is the excel showing the tabs
Here is the whole code below:
Dim oDoc As Inventor.DrawingDocument oDoc = ThisDoc.Document Dim oPartslist As PartsList Dim oSheet As Inventor.Sheet 'look at each sheet For Each oSheet In oDoc.Sheets 'get the first parts list on the sheet Try oPartslist = oSheet.PartsLists(1) 'get the path and name of the drawing file path_and_name = ThisDoc.PathAndFileName(False) ' without extension ' create a new NameValueMap object oOptions = ThisApplication.TransientObjects.CreateNameValueMap 'get the user name from the Inventor Options myName = ThisApplication.GeneralOptions.UserName 'specify the columns to export oOptions.Value("ExportedColumns") = "ITEM;PART #;DESCRIPTION;LENGTH;ITEM QTY;CATEGORY;FINISH" 'specify the start cell oOptions.Value("StartingCell") = "A1" 'specify the XLS tab name 'here the file name is used oOptions.Value("TableName") = ActiveSheet.sheet.name(False) 'without extension 'choose to include the parts list title row 'in this example "Ye Old List of Parts" is written to the StartingCell oOptions.Value("IncludeTitle") = False 'choose to autofit the column width in the xls file oOptions.Value("AutoFitColumnWidth") = True ' export the Partslist to Excel with options oPartslist.Export("C:\Users\" & myName & "\Desktop\EAP Cutlist Master.xlsx", PartsListFileFormatEnum.kMicrosoftExcel, oOptions) Catch End Try Next 'tell the user the files were created MessageBox.Show("All BOM's have been exported.")
Solved! Go to Solution.