I have a form with a value I need to check before the document (created from a template) is saved and printed. Events are registered fine. The override function is in place. I know the code is executing, however when I try to read the value
the user has typed into the form field I get the default value. I can't understand why. The relevant code is listed below:
Private Function CheckCODAmt() As Boolean
Dim o As FormFields
Dim oIB As FormField
Dim sVal As String
Dim bRet As Boolean
' set/initialize
Set o = ThisDocument.FormFields
sVal = ""
bRet = True
' check for COD amount as legit
For Each oIB In o
If oIB.Name = "Text13" Then
' it gets into here and only returns the default value from the template
MsgBox oIB.Name & " -- " & oIB.Range.Text
MsgBox oIB.Result
End If
Next
CheckCODAmt = bRet
End Function
UPDATE:
The issue seems to be around the template macro being able to interact with the document that called it. If I use:
ActiveDocument.FormFields("Text13").Range.Fields(1).Result
I get a "No open documents" error
Word.Documents(1).FormFields("Text13").Range.Fields(1).Result
I get the expected results.
This would seem to indicate that the template has no ability to reach or interact with content on the referrer... that seems odd. What am I missing?