Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
it seems there is something difficult with defining oSheet in my oOptionsBOM
i'm not sure
Imports System.Windows.Forms ' Get current location of this file Dim ExportPath As String = ThisDoc.Path ' Check that this file has been saved and actually exists on disk If String.IsNullOrEmpty(ExportPath) Then MsgBox("This file has not yet been saved and doesn't exist on disk! - please save it first", 64, "Cadline iLogic") Return End If ' Define folder browse dialog Dim Dialog = New FolderBrowserDialog() ' Set optionsBOM for folder browser dialog Dialog.SelectedPath = ExportPath Dialog.ShowNewFolderButton = True Dialog.Description = "Please choose Release Folder" ' Show dialog box If DialogResult.OK = Dialog.ShowDialog() Then ' User clicked 'ok' on dialog box - capture the export path ExportPath = Dialog.SelectedPath & "\" Else ' User clicked 'cancel' on dialog box - exit Return End If 'Export to XLS 'define oDoc................oDoc can be many documents, in this case you need the drwaing document Dim oDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument 'specify the ACTIVE drawing sheet Dim oSheet As Sheet = oDrawDoc.ActiveSheet '=active sheet!! ....... = oDoc.Sheets(1) ' first sheet ' say there is a Partslist on the sheet. what if there are more then one? Dim oPartslist As Inventor.PartsList = oSheet.PartsLists(1) ' create a new NameValueMap object Dim oOptionsBOM As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap 'specify an existing template file'to use For formatting colors, fonts, etc oOptionsBOM.Value("Template") = "C:\Users\cbn\Desktop\christian projekter\stuff\Partslist.xls" 'specify the columns to export oOptionsBOM.Value("ExportedColumns") = "ITEM#;QTY;PART#;MATERIAL;DESCRIPTION;COMMENTS;COM CODE;TOTAL WT." 'specify the start cell oOptionsBOM.Value("StartingCell") = "B11" 'specify the XLS tab name'here the file name is used oOptionsBOM.Value("TableName") = "BILL OF MATERIALS" 'choose to include the parts list title row'in this example "Ye Old List of Parts" is written to the StartingCell oOptionsBOM.Value("IncludeTitle") = False 'choose to autofit the column width in the xls file oOptionsBOM.Value("AutoFitColumnWidth") = True 'get BOMrget folder path Dim oFolderBOM As String = Strings.Left(ExportPath, InStrRev(ExportPath, "\")) & "BOM" 'Check for the BOM folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolderBOM) Then System.IO.Directory.CreateDirectory(oFolderBOM) End If ' export the Partslist to Excel with optionsBOM oPartslist.Export(oFolderBOM & "\" & oSheet.Name & ".xls", PartsListFileFormatEnum.kMicrosoftExcel, oOptionsBOM)
Solved! Go to Solution.