Relatively new to VBA coding.


I’ve set up a word document with a user form that works fine via custom properties. Example of code below:


Private Sub OK_Click()

' Update the properties values
ThisDocument.CustomDocumentProperties("customTitle").Value = Me.DocumentTitle.Value
ThisDocument.CustomDocumentProperties("customStartDate").Value = Me.CertDate.Value
ThisDocument.CustomDocumentProperties("customProjectNo").Value = Me.ProjectNo.Value
ThisDocument.CustomDocumentProperties("customEqDescription").Value = Me.EqDescription.Value
ThisDocument.CustomDocumentProperties("customClientName").Value = Me.ClientName.Value
ThisDocument.CustomDocumentProperties("customClientContact").Value = Me.ClientContact.Value
ThisDocument.CustomDocumentProperties("customOwnerPhoneNo").Value = Me.OwnerPhoneNo.Value
ThisDocument.CustomDocumentProperties("customOwnerEmail").Value = Me.OwnerEmail.Value
ThisDocument.CustomDocumentProperties("customRevisionNo").Value = Me.RevisionNo.Value
' Show changes of document properties in document
ThisDocument.Fields.Update

' Hide the userform
UserForm1.Hide

End Sub

Problem is when I save and open an existing document the data is not saved in the user form. If I hit enter on the user form it wipes all entries in the document.
Would be good if the user form could retain the old inputs. Is this doable, and does someone have some code that does this?

Appreciate any advice...