Hi,
I have a drawing files with 15 - 25 sheets in them and on most sheets there is a drawing of a single part but some have multiple. I want to generate a STEP file from every part, and want every STEP to have the same name as it's original part. I Have tried to use some of the macros I have found online but they only save the first model it grabs as a step file and doesn't iterate through each page. Any help with something that would work would be appreciated.
Thanks!

Try this macro.
'by John R. Sitek
'07-APR-2025
'This macro loops views to save out STEP files
Option Explicit
Sub Main()
Dim swApplication As SldWorks.SldWorks
Dim swDrawing As SldWorks.DrawingDoc
Dim swModel As ModelDoc2
Dim swExportPdfData As SldWorks.ExportPdfData
Dim swAdvancedSaveAsOptions As SldWorks.AdvancedSaveAsOptions
Dim swFileSaveErrors As swFileSaveError_e
Dim swFileSaveWarnings As swFileSaveWarning_e
Dim vbViews As Variant
Dim vbSheet As Variant
Dim vbView As Variant
Dim vbSTEPFileName As String
Set swApplication = Application.SldWorks
'If nothing is open
If swApplication.ActiveDoc Is Nothing Then
MsgBox "Please open a drawing file, then rerun the macro.", vbOKOnly, "For Drawings"
Exit Sub
End If
'If current file is not a drawing
If Not swApplication.ActiveDoc.GetType = swDocDRAWING Then
MsgBox "Please open a drawing file, then rerun the macro.", vbOKOnly, "For Drawings"
Exit Sub
End If
Set swDrawing = swApplication.ActiveDoc
vbViews = swDrawing.GetViews
'Loop sheets
For Each vbSheet In vbViews
'Loop views
For Each vbView In vbSheet
If Not vbView.Type = swDrawingSheet Then
Set swModel = vbView.ReferencedDocument
If UCase(swModel.GetTitle) Like "*SLDASM*" Then
vbSTEPFileName = Replace(swModel.GetPathName, ".SLDASM", "-ASM.STEP", 1, -1, vbTextCompare)
'Save assembly to STEP file
swModel.Extension.SaveAs3 vbSTEPFileName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, swExportPdfData, swAdvancedSaveAsOptions, swFileSaveErrors, swFileSaveWarnings
End If
If UCase(swModel.GetTitle) Like "*SLDPRT*" Then
vbSTEPFileName = Replace(swModel.GetPathName, ".SLDPRT", "-PART.STEP", 1, -1, vbTextCompare)
'Save part to STEP file
swModel.Extension.SaveAs3 vbSTEPFileName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, swExportPdfData, swAdvancedSaveAsOptions, swFileSaveErrors, swFileSaveWarnings
End If
End If
Next vbView
Next vbSheet
End Sub
We've been using a program called PAC4SWX for a long time. It will allow you to do multiple things including convert to any of the files that SW will save to. It won't read what files are included in the drawing file as you have to drag the files into the program you want translated but that's a simple drag & drop from a folder