Run recorded macro on all files in folder

I wish to change all configuration names with are "Default" to "00".

I have the recorded macro below which works on the open part. How can I modify this to run on all parts in a given folder?

Thanks in advance!

Dim swApp As Object

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

Dim myModelView As Object

Set myModelView = Part.ActiveView

myModelView.FrameState = swWindowState_e.swWindowMaximized

boolstatus = Part.Extension.SelectByID2("Default", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = Part.EditConfiguration3("Default", "00", "", "", 36)

End Sub

SolidworksApi macros
Answers 6
MD
MD 2017-08-29 Best Answer

Why don't you run it in the SOLIDWORKS Task Scheduler?

DG
DG 2017-08-29

You can use #TASK tool to batch run your macro.

MK
MK 2017-08-29

The example at this SolidWorks forum link might help you:

CC
CC 2017-09-12

Both Dim longstatus As Long, longwarnings As Long are declared but never used?

GK
GK 2017-09-12

I believe that is what SW macro recorder generated. You're saying it's ok to delete those variables?

Matlab is the closest I've ever come to programming.

CC
CC 2017-09-12

Yes, it'd make your program cleaner and more understandable but it won't hurt to leave them there