Need API Macro to check drawings for sheets without any views

We have had users release drawings with extra sheets that have zero views.  Need a macro for design checker to alert this Solidworks User as a custom check. 

Answers 4
DM
DM 2025-06-19

why do your drawings have so many pages? 

KM
KM 2025-06-20

Do you have an example print? Are the views just hidden?

MJ
MJ 2025-06-21

something like this?


Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swDrawing As DrawingDoc
Dim swSheet As Sheet
Dim sheetNames As Variant
Dim vViews As Variant
Dim vView As Variant
Dim swView As View
Dim i As Long

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel.GetType <> swDocumentTypes_e.swDocDRAWING Then
   Exit Sub
End If

Set swDrawing = swModel
Set swSheet = swDrawing.GetCurrentSheet
sheetNames = swDrawing.GetSheetNames

For i = 0 To UBound(sheetNames)

   Set swSheet = swDrawing.Sheet(sheetNames(i))

   vViews = swSheet.GetViews
   If IsEmpty(vViews) Then
       swApp.SendMsgToUser2 swSheet.GetName & " has no views! Please check whether the sheet is still required!", swMessageBoxIcon_e.swMbWarning, swMessageBoxBtn_e.swMbOk
   End If
Next i


End Sub
 

SB
SB 2025-06-27

Some of our users inadvertently add a sheet and release it in that state.o Title block will show "Sheet 1 of 2" When the second sheet is just a mistake and empty.