I’m trying to open a Word template and update its fields using CustomDocumentProperties in a VB.Net Windows form application. This is working for regular field content, but I want the UpdateFields event to trigger custom code within the Word template.
This is what I have in the Word template:
Public Sub UpdateFields()
'do some things with the CustomDocProperties
End Sub
And this is the code from the application:
Dim wordApp = New Word.Application
wordApp.Documents.Open(pathToTemplate)
wordApp.ActiveDocument.CustomDocumentProperties("Initials").Value = "JD"
wordApp.ActiveDocument.Fields.Update()
The UpdateFields method is triggered when I update the fields in Word itself, but this does not happen when I do this through interop.
Used following line to call custom method:
wordApp.Run("InsertSignature", "JD")