Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Curtis_Waguespack
in reply to: Anonymous

Hi rtrayes13,

 

Here is the same rule with a Try/Catch/End Try added that will handle the error created when a sheet doesn't have a parts list.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oDoc As Inventor.DrawingDocument
oDoc = ThisDoc.Document
Dim oPartslist As PartsList
Dim oSheet As Inventor.Sheet

'get folder (using the same path as this doc)
folderName = ThisDoc.Path


	'look at each sheet
	For Each oSheet in oDoc.Sheets
	'get the first parts list on the sheet
	Try
	oPartslist = oSheet.PartsLists(1)
	'replace colon in sheet name with underscore
	oName = Replace(oSheet.Name, ":","_") 
	'export each parts list
	oPartslist.Export(folderName & "\" & oName  & ".xls", PartsListFileFormatEnum.kMicrosoftExcel)
	Catch
	End Try
	Next 


'tell the user the files were created
MessageBox.Show("New *.xls files created in: " _
&vblf & folderName, "iLogic")

'open the folder where the new folders are saved
Shell("explorer.exe " & folderName & "\" ,vbNormalFocus)