I would not know how to write a macro to do this. How difficult would it be?
Will *pd* be in the file name and/OR properties? Can you share some files?
Examples of file names 00-1193-512-00-PD1.SLDRW, 00-1193-512-00-PD2.SLDDRW, 00-2255-567-00-PD3.SLDDRW. Files are in multiple drives and folders. We have 2900 files we need to convert.
Enter the filter, in your case *pd*.slddrw, in the Open Dialog Box of the SolidWorks Task Scheduler and press Enter. Then select all the files that are listed. If the files are stored in many different directories, a macro is the better choice.
*pd*.slddrw will not work in the task scheduler it converts all slddrw files. We have 20,000 slddrw files but only 2,900 fliles with pd in them which are the only ones we want to convert. I saw in a previous post from 2015 where someone was trying to do the same thing.
If you enter in the file name it works fine. If you use *.slddrw it works fine. If you use *pd*.slddrw it works fine except in both cases you convert all slddrw files. What we are trying to do is convert 2,000 slddrw files with pd in the file name without converting the 20,000 slddrw files. We want to be able to convert them and save them in there current folders.
Print the page, but instead of printing it to a printer choose print to pdf.
If all of the required file names are the same length before and after the "PD", then how about trying the single character wild card "?".
So "00-1193-512-00-PD1.SLDRW" would be "???????????????PD?.SLDRW".
You may also be able to leave the hyphens in if that helps for clarity.
If you try using ? in task scheduler it says it is a illegal character.
Sorry that didn't work out.
DIR "???????????????PD?.SLDRW" /b > C:\path\PDfiles.txt
Then do a FOREACH statement referencing the above file.
Review the text file dump file to be sure it has only the file names of interest.
I prepared a macro to search for drawing files which has "pd" in title in a specific folder, opens them one by one, saves as pdf in same folder and closes it after continuing to next one. Test it first in a seperate folder
Dim swApp As Object
Set swApp = Application.SldWorks
Dim fol1, fol2
path = "enter your folder path"
Set fol1 = CreateObject("scripting.filesystemobject")
Set fol2 = fol1.GetFolder(path)
For Each boyut In folderSet.Files
If InStr(boyut.Name, "pd") Or InStr(boyut.Name, "PD") Then
If InStr(boyut.Name, "slddrw") Or InStr(boyut.Name, "SLDDRW") Then
For Each klasor In folderSet.SubFolders
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swExportPDFData As SldWorks.ExportPdfData
Dim err As Long
Dim warr As Long
Dim lErrors As Long
Dim lWarnings As Long
Dim status As Boolean
Dim partTitle As String
Set swModel = swApp.OpenDoc6(drawingName, swDocDRAWING, swOpenDocOptions_Silent, "", err, warr)
'swApp.SetCurrentWorkingDirectory (Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\")))
Set swModelDocExt = swModel.Extension
Set swExportPDFData = swApp.GetExportFileData(1)
swExportPDFData.ViewPdfAfterSaving = False
status = swModelDocExt.SaveAs(Replace(drawingName, "SLDDRW", "pdf"), 0, 0, swExportPDFData, lErrors, lWarnings)
partTitle = swModel.GetTitle
Private Function Delay(count As Long)
Dim start As Long
Dim i As Long
i = 0
start = Timer
Do While Timer < start + count
Macro works great. Thank you!!!!!!!!!!!!
Thanks, glad to be of help