How can i get current sheet number in a drawing document ? ?
How can i get current sheet number in a drawing document ? ?
I don't think there is direct way to get the sheet number. You can get the sheet name and ID though.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Debug.Print swSheet.GetName & " " & swSheet.GetID
End Sub
Actually, there is a way to find the sheet number using the DrawingDoc.Sheetnames method
Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDraw As SldWorks.DrawingDoc Dim swSheet As SldWorks.Sheet Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDraw = swModel Set swSheet = swDraw.GetCurrentSheet Dim swSheetName As String swSheetName = swSheet.GetName Dim swSheetNames As Variant swSheetNames = swDraw.GetSheetNames Dim SheetNumber As Long Dim I As Integer For I = 1 To UBound(swSheetNames) + 1 If swSheet.GetName = swSheetNames(I - 1) Then SheetNumber = I Exit For End If Next I Debug.Print "Sheet name: "; swSheet.GetName & " Number: " & SheetNumber End Sub
Great, thanks for sharing that. I was using .SheetNames but could not work out these lines
If swSheet.GetName = swSheetNames(I - 1) Then
SheetNumber = I
Actually, there is a way to find the sheet number using the DrawingDoc.Sheetnames method