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 macro from )
For starting the macro on start, I followed recommendation from https://forum.solidworks.com/thread/34089#387860 )
To run the macro when a save event is fired, I tried following from , , 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
Extracting properties from file name macro (credit , ). 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