What is the easiest way to run a macro on all sheets in a drawing.
What is the easiest way to run a macro on all sheets in a drawing.
Put your code in DoTheWork().
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 i As Integer Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc If swModel Is Nothing Then Exit Sub If swModel.GetType <> swDocDRAWING Then Exit Sub Set swDraw = swModel vSheetNames = swDraw.GetSheetNames For i = 0 To UBound(vSheetNames) swDraw.ActivateSheet vSheetNames(i) DoTheWork swDraw Next i End Sub Private Sub DoTheWork(swDraw As SldWorks.DrawingDoc) MsgBox swDraw.GetCurrentSheet.GetName End Sub
Keith
Not sure if the attached will get you the info you need, but I'll give it a shot
Written by Deepak Gupta and edited by Garrett Hansen