Get Sheet Numbers and Names Example (VBA)
This example shows how to get the sheet numbers and names for multiple
sheets in a drawing document.
'---------------------------------------------
'
' Preconditions: Drawing document is open and has multiple
sheets.
'
' Postconditions: None
'
'---------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swDraw As
SldWorks.DrawingDoc
Dim
swSheet As
SldWorks.sheet
Dim
vSheetNames As
Variant
Dim
bRet As
Boolean
Dim
i As
Long
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swDraw = swModel
Set
swSheet = swDraw.GetCurrentSheet
Debug.Print
"FileName = " + swModel.GetPathName
Debug.Print
" Current
sheet = " & swSheet.GetName
Debug.Print
""
vSheetNames
= swDraw.GetSheetNames
For
i = 0 To UBound(vSheetNames)
Debug.Print
" SheetName["
& i & "] = " & vSheetNames(i)
Next
i
End Sub
'---------------------------------------------