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

@GosponZ you can try something like this. It is a slight modification to your code. It will not error when it finds a page without a view & it will just remove all characters that are not letters or digits except for spaces.

 

 

 

Dim oDoc As Document = ThisDoc.Document
Dim oSheets As Sheets = oDoc.Sheets
For Each oSheet In oSheets
    oSheet.Activate
	Dim oView As DrawingView
	Try
    	oView = oSheet.DrawingViews.Item(1)
	Catch
		'MessageBox.Show("There is no drawing view on " & oSheet.Name)
		Continue For
	End Try
    Dim modelName As Object = oView.ReferencedDocumentDescriptor.ReferencedDocument
    Dim oProp As PropertySet = modelName.PropertySets.Item("Design Tracking Properties")
	'ocProp = modelName.PropertySets.Item("Inventor User Defined Properties") 'Custom property set
	Try
		Dim oSheetName As String = oProp.Item("Part Number").Value & " " & oProp.Item("Description").Value  '_
                '& " " & "QTY" & " " & ocProp.Item("TTL").Value
		Dim oDisplayName As String = ""
		
		For Each letter As Char In oSheetName
			If Char.IsLetterOrDigit(letter) Or Char.IsWhiteSpace(letter) Then
				oDisplayName = oDisplayName & letter
			End If
		Next
		ActiveSheet.Sheet.Name = oDisplayName
	Catch
		'MessageBox.Show("Couldn't change sheet name for " & oSheet.Name)
	End Try
Next
oSheets(1).Activate
iLogicVb.UpdateWhenDone = True

 

 

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.