BOM Export

BOM Export

dsavian
Explorer Explorer
261 Views
4 Replies
Message 1 of 5

BOM Export

dsavian
Explorer
Explorer

Hi there,

I would  like to export the BOM using ILogic, and save automatically the file like an .xls with the same name of the project I'm working on.

Anyone can help me?

0 Likes
262 Views
4 Replies
Replies (4)
Message 2 of 5

llorden4
Collaborator
Collaborator

Perhaps this previously asked question might help?

https://forums.autodesk.com/t5/inventor-programming-ilogic/export-bom-with-ilogic-inventor-2022/td-p...

Autodesk Inventor Certified Professional
0 Likes
Message 3 of 5

dsavian
Explorer
Explorer

ok but i need to save the bom file with the same name of the assembly i'm working, automatically, without writing by hand the name.

 

Dim oFile As String = ThisDoc.FileName(False)

thisBOM.Export("Structured", "oFile.xlsx", kMicrosoftExcelFormat)

Like this but doesnt work

 

0 Likes
Message 4 of 5

nick5MWHR
Contributor
Contributor

Try this:

 


oPath = ThisDoc.Path 
oFileName = ThisDoc.FileName(False) 'without extension
ExcelFileName = oPath & "\" & "RandomText- " & oFileName & ".xlsx"
0 Likes
Message 5 of 5

Mehmet_Fatih_Turker
Advocate
Advocate
    Try
		
        Dim projectDirectoryName As String = GetProjectDirectoryName()
        Dim projectDirectoryPath As String = GetProjectDirectoryPath()
		
        saveDialog.FileName = projectDirectoryName & " - Replaced Components " & strFileNamePrefix & " to " & OverridedPartNamePrefix & ".xlsx"
        saveDialog.Filter = "Excel Workbook|*.xlsx"
        saveDialog.Title = "Save Excel File"
        saveDialog.InitialDirectory = projectDirectoryPath

        Dim DialogResult As DialogResult = saveDialog.ShowDialog()

        If DialogResult = DialogResult.OK Then
			
            If Not String.IsNullOrEmpty(saveDialog.FileName) Then
                
                workbook.SaveAs(saveDialog.FileName)
                MessageBox.Show("Export successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
				
            Else

				MessageBox.Show("Export cancelled or encountered an error.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
            
			End If
        
		End If
    
	Catch ex As Exception
       
	   MessageBox.Show("An error occurred while exporting to Excel: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    
   Finally

        If workbook IsNot Nothing Then workbook.Close(False)
        If excelApp IsNot Nothing Then excelApp.Quit()

        ReleaseObject(worksheet)
        ReleaseObject(workbook)
        ReleaseObject(excelApp)
    
	End Try


This snippet is the one that I used in order to export custom-created list to excel. Hope it will help. Basicaly;

        saveDialog.FileName = projectDirectoryName & " - Replaced Components " & strFileNamePrefix & " to " & OverridedPartNamePrefix & ".xlsx"
        saveDialog.Filter = "Excel Workbook|*.xlsx" 'this indicates save as file type
saveDialog.Title = "Save Excel File" 'this indicates save as window title name
saveDialog.InitialDirectory = projectDirectoryPath 'this indicates save path


This part of code does all the work. Hope it will help !

 

0 Likes