Hi All, I am trying to save the pdf of the drawing through a Macro.
I am using the Macro below and It is working perfectly.
At the moment the pdf is saved in the same location as the drawing.
The question is, How can I save the pdf in a different location in PDM?
Thanks
<pre style="border: 1px solid #ff6000;">Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swExportPDFData As SldWorks.ExportPdfData Dim strFilename As String Dim status As Boolean Dim errors As Long, warnings As Long Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc 'Save status = swModel.Save3(swSaveAsOptions_e.swSaveAsOptions_Silent, errors, warnings) 'Export to PDF if it is a drawing If (swModel.GetType = swDocDRAWING) Then strFilename = swModel.GetPathName strFilename = Left(strFilename, Len(strFilename) - 6) & "pdf" Set swExportPDFData = swApp.GetExportFileData(1) swModel.Extension.SaveAs strFilename, 0, 0, swExportPDFData, 0, 0 End If End SubSolidworksApi/macros

John, sorry for a late reply. I hope Bret's solution is working perfectly for you. In case you get error on selecting desktop, then check the codes in this post In addition there is macro (in the same post) to list all part files in the selected folder (in case you want to check that out)
Thank you so much for your prompt response to the question.
I will give it a good try
Cheers
Wow! Thanks Brett,
I wonder where that had been hiding. Google and Microsoft have been very cagey about what you're supposed to freakin' do after the retirement of VB6. I've had my macros all hobbled since VBA7 came out in (what was it 2014?)
You da' man!
John, might have done what i think your asking for hopefully this helps
For this make sure you add a reference to C:\windows\sysWOW64\shell32.dll 'Microsoft Shell Controls and Automation'
Private Sub Select_Folder_Click()
Dim MyPath As String
MyPath = SelectFolder("Select Folder", "C:\")
Location.Text = MyPath
End Sub
Function SelectFolder(Optional Title As String, Optional TopFolder _
As String) As String
Dim objShell As New Shell32.Shell
Dim objFolder As Shell32.Folder
Set objFolder = objShell.BrowseForFolder _
(0, Title, 1, TopFolder)
If Not objFolder Is Nothing Then
SelectFolder = objFolder.Items.Item.Path
End If
End Function
Deepak, have you had any luck getting the select folder dialog in VBA so that you can add a browse button to specify the path to this macro?
I've heard there's a control you can borrow from the excel api, but then it's the Common Dialog control all over again.
Not sure on how to save inside PDM but for outside PDM, try following codes