5 Replies Latest reply on Dec 23, 2015 7:03 AM by Mikael Bolduc

    How can i get current sheet number API

    Mikael Bolduc

      How can i get current sheet number in a drawing document ? ?

        • Re: How can i get current sheet number API
          Deepak Gupta

          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

          • Re: How can i get current sheet number API
            Amen Allah Jlili

            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