Context
I am starting on API and starting with VBA. I was trying to open a new part with a given part template and then saving it to a specific location. Initially, I was able to save to the exact location without using any Advanced save options. However, it was returning message for Else condition regardless of if it was returning 'True' value for 'BooSaved' variable.
Now, I figured out I was using SaveAs3 wrong way and not through extension. I changed it to include Errors and other advanced options as they weren't optional in ModelDocExtension SaveAs3 method. However, it has stopped saving the parts to location with the name specified. But still returns the 'True' for 'BooSaved' variable, while message box shows, message for false condition.
Also, more resources that has good simplified ways to explain VBA for Solidworks to me would be appreciated. I started on with Solidwork API Series 1 by Luke Malpass. However, it is mainly based on another language.
Thanks in Advance
The code
Option Explicit Dim swApp As SldWorks.SldWorks Dim swPart As SldWorks.ModelDoc2 Dim Extension As SldWorks.ModelDocExtension 'Dim Part As SldWorks.PartDoc Dim SamTemplate As String Dim myFolder As String Dim AdvDataOpt As AdvancedSaveAsOptions Sub main() Set swApp = Application.SldWorks SamTemplate = "C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2024\templates\Sam.prtdot" Set swPart = swApp.NewDocument(SamTemplate, 0, 0, 0) swApp.Visible = True swPart.ViewZoomtofit2 'Set swPart = swApp.ActiveDoc Set Extension = swPart.Extension Set AdvDataOpt = Extension.GetAdvancedSaveAsOptions(0) Dim BooSaved As Boolean Dim IErrors As Long Dim IWarnings As Long 'myFolder = "Z:\A STAFF FOLDERS\SAMMY\MACROS\Learning Macros\NewRandomPart.sldprt" BooSaved = Extension.SaveAs3(myFolder, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, AdvDataOpt, IErrors, IWarnings) 'SwConst.swSaveAsOptions_e.swSaveAsOptions_Silent You can write the whole arguement with sWConst to give context to it. Rather than using whole arguement of accessing SaveAs enums through constant libraries, you can just write a number for that enum. You can also have multiple arguements with using a +. If BooSaved = True Then MsgBox "Fuck Yeah! Did it" Else MsgBox "Fucking Couldn't save it" End If Debug.Print BooSaved End Sub