Is there a way to run a macro on all open drawings?
so lets say I open up 20 different drawings (could be different file locations), click the macro button and have it cycle through them all? I tried to record this function and it always used the file name. I'm assuming there is a way to do like what you would for a batch folder run macro, but I don't know how.
I wish to have the macro save each open drawing as a pdf file name being a custom property. macro below.
'File Save As PDF
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swCustProp As CustomPropertyManager
Dim valOut As String
Dim resolvedValOut As String
Dim Filepath As String
Dim FileName As String
Sub main()
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
If (swDraw Is Nothing) Or (swDraw.GetType <> swDocDRAWING) Then
swApp.SendMsgToUser ("To be used for drawings only, Open a drawing first and then TRY AGAIN!")
Exit Sub
End If
Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
Set swModel = swView.ReferencedDocument
Set Sheet = swApp.ActiveDoc.GetCurrentSheet
Set swCustProp = swModel.Extension.CustomPropertyManager("")
swCustProp.Get2 "dwgnumber1", valOut, resolvedValOut 'Change the custom property name here
Filepath = Left(swDraw.GetPathName, InStrRev(swDraw.GetPathName, "\"))
FileName = Left(swDraw.GetTitle, Len(swDraw.GetTitle) - 9)
swDraw.SaveAs (Filepath + resolvedValOut + ".PDF") 'Change the custom property text here
End Sub