I have this kind of macro
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swExportData As SldWorks.ExportPdfData
Dim boolstatus As Boolean
Dim filename As String
Dim lErrors As Long
Dim lWarnings As Long
Dim amountSaved As Double
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
amountSaved = 0
If swModel Is Nothing Then
MsgBox "Ei Olemassa Olevaa Tiedostoa", vbCritical
End
End If
If swModel.GetType <> swDocDRAWING Then
MsgBox "Tämä Macro Toimii Vain Työkuva Näkymässä", vbCritical
End
End If
Set swModelDocExt = swModel.Extension
Set swExportData = swApp.GetExportFileData(swExportPdfData)
filename = swModel.GetPathName
If filename = "" Then
MsgBox "Tallenna Tiedosto ensin ja kokeile uudestaan", vbCritical
End
End If
'Save drawing
boolstatus = swExportData.SetSheets(swExportData_ExportAllSheets, 1)
boolstatus = swModelDocExt.SaveAs(filename, 0, 0, swExportData, lErrors, lWarnings)
If boolstatus Then
amountSaved = amountSaved + 1
Else
On the part
If filename = "" Then
MsgBox "Tallenna Tiedosto ensin ja kokeile uudestaan", vbCritical
If SLDDRW solidworks drawing isn't yet saved this MsgBox says this file not yet saved.
I would like this to work so that if the drawing isn't saved It would save it with the same name as the part name. This is normally the preference.
Ideally I would get MsgBox that would ask "drawing is not saved do you want to save this drawing with the name of part1.SLDDRW"
Then just an option to hit ok or cancel and preferably the ok already highlighted Is this even possible.
Rest of my macro is just to save PDF and DXF. But I just want this so I can save all 3 at the same time even though SLDDRW is never saved before.
Thanks in advance
SolidworksApi macros