I have VBA code to issue drawings. It allows properties of the model to be changed, issue, date of issue etc.
The idea is to open the drawing, update issue, date, etc. (save as pdf and dwg). It works, properties changed, and saves the correct view.
The property changes are not saved to the model, unless I open the model and force a save, hence when I reopen the drawing/model they revert to the old.
How can I force a save of the model, even if it is not open?
See last few lines for my attempt:
Sub WriteModelProperties(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2)
Dim element As Integer
Dim boolstatus As Boolean
Dim ctrl As MSForms.Control
Dim fieldName As String
Dim fieldType As Integer
Dim fieldValue As String
For element = 0 To 25
fieldName = propertiesValue(0, element)
Select Case propertiesValue(1, element)
Case "Text": fieldType = 30
Case "Date": fieldType = 64
End Select
Set ctrl = UserForm1.Controls(propertiesValue(2, element)) 'to make a compact code
Select Case propertiesValue(3, element)
Case "Caption": fieldValue = ctrl.Caption
Case "Value": fieldValue = ctrl.Value
End Select
Debug.Print fieldValue
boolstatus = swCustProp.Add3(fieldName, fieldType, fieldValue, swCustomPropertyDeleteAndAdd)
Next element
swModel.Rebuild (swRebuildAll)
swModel.EditRebuild3 ' Update model properties
swModel.ViewZoomtofit2
boolstatus = swModel.Save3(swSaveAsOptions_Silent, lErrors, lWarnings)
End Sub