Hello Everyone,
I am very new to VB programming and will really appreciate if someone can help.
Desired output:
1. A user presses save or (ctrl-s) in either part, assembly or drawing.
2. It runs a macro which extracts the properties from filename.
3. Macro should also run when the autosave kicks in for either part, assembly or drawing
Requirements: User should not be required to run the macro
I have the macro which extracts properties from filename (used Deepak Gupta macro from Custom Properties - Part of a file name)
For starting the macro on start, I followed Deepak Gupta recommendation from https://forum.solidworks.com/thread/34089#387860 )
To run the macro when a save event is fired, I tried following from Amen Allah Jlili, Deepak Gupta, Wayne Matus and @Tobin_Sparks. But, I cannot understand the code and hence dont know what to change.
Will appreciate if someone can put sample code.
Reference:
Deepak gupta and Wayne Matus : https://forum.solidworks.com/thread/21658#88655
Tobin sparks: PreSave
Filipe Venceslau recommendation Run macro when saving
Extracting properties from file name macro (credit Deepak Gupta, Matt Martens). This is working fine, but user has to run the macro.
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.DeleteCustomInfo ("PartNo")
swModel.AddCustomInfo2 "PartNo", swCustomInfoText, Left(swModel.GetTitle, 6)
swModel.DeleteCustomInfo ("Rev")
swModel.AddCustomInfo2 "Rev", swCustomInfoText, Mid(swModel.GetTitle, 8, 1)
swModel.DeleteCustomInfo ("Title")
swModel.AddCustomInfo2 "Title", swCustomInfoText, Mid(swModel.GetTitle, 10, 50)
End Sub
Thank you in advance.
KK
Try updated attached macro for Save As but I do not think there is a notify event for Save All