Macro to change the template for multiple drawing files?
Macro to change the template for multiple drawing files?
(OP)
I have about 150 drawing files that need to be changed to have a new drawing template. Some of the drawings have multiple sheets.
Does anyone have a macro that will batch change all of the drawing files?
Does anyone have a macro that will batch change all of the drawing files?






RE: Macro to change the template for multiple drawing files?
Try the TemplateSwitch macro from http
RE: Macro to change the template for multiple drawing files?
Now, how would be the best way to go about applying this macro to all of the files without going through each one manually? I was thinking it could be done in the SolidWorks Task Scheduler, but I seem to be missing how to run it for certain folders?
RE: Macro to change the template for multiple drawing files?
FAQ559-1429: How to change or manage document properties.
RE: Macro to change the template for multiple drawing files?
Thanks,
Matt
RE: Macro to change the template for multiple drawing files?
Are you saying that none of the programs listed in the above FAQ worked for you?
RE: Macro to change the template for multiple drawing files?
I started a macro but am having trouble with the SetupSheet4 function.
-Matt
RE: Macro to change the template for multiple drawing files?
The free version allows changes to (I beleive) five files at a time. The purchased version is not limited.
RE: Macro to change the template for multiple drawing files?
RE: Macro to change the template for multiple drawing files?
I also want to learn, so if any VB/macro gurus can take a look at this and explain why I can't save the active document in my macro, I'd appreciate it. This is just meant to work - there's very little in the way of functionality or error handling.
-Matt
CODE
' chgfmt.swb - macro recorded on 08/11/08 by mdenardo
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim MyDir As String
Dim MySheet As String
Dim MyFile As String
Sub main()
Set swApp = Application.SldWorks
MyDir = InputBox("Enter the path that contains the files you want to change.")
MySheet = InputBox("Enter the full path, including file name and extension of the sheet format you want to use.")
MyFile = Dir(MyDir & "\*.slddrw")
Do While MyFile <> ""
MyFile = Dir()
FileName = Split(MyFile, ".")
Set Part = swApp.OpenDoc6(MyDir & "\" & MyFile, 3, 0, "", longstatus, longwarnings)
swApp.OpenDoc6 MyDir & "\" & MyFile, 3, 0, "", longstatus, longwarnings
Set Part = swApp.ActivateDoc2(FileName(0) & " - Sheet1", False, longstatus)
swApp.ActiveDoc.ActiveView.FrameLeft = 0
swApp.ActiveDoc.ActiveView.FrameTop = 0
swApp.ActiveDoc.ActiveView.FrameState = 1
swApp.ActiveDoc.ActiveView.FrameState = 1
boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.1391084233669, 0.2266029916164, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Part.SetupSheet4 "Sheet1", 12, 12, 1, 1, False, MySheet, 0.4318, 0.2794, "Default" ', True
Part.ViewZoomtofit2
retval1 = Part.Save3()
Set Part = Nothing
swApp.CloseDoc FileName(0) & " - Sheet1"
Loop
End Sub
RE: Macro to change the template for multiple drawing files?
CODE