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

The only error I could bring up is when no model was present in one of the sheets. As this rule loops through all sheets and looks for view (1) if missing it will error out. Included in the rule below is an error trap for skipping the sheet renaming when no view is present. If this still doesn't work can you post the error message that you have received?

 

Sub Main()
'Purpose: Push file name to sheet name
'21-Sept-16

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView


'Iterate through sheets
For Each oSheet In oDoc.Sheets
	
	Try
    'Grab the first drawing view on the sheet
    oDrawingView = oSheet.DrawingViews(1)

    'Grab the model of the first drawing view
    oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument 

     'Assign the sheet name based off of the file name, with the path and extension removed
    oSheet.Name = System.IO.Path.GetFileNameWithoutExtension(oModel.FullFileName)
	
	Catch
		'Error no view so skip
	End Try
Next 
  
End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan