Word 2010 Reading Values on Form Fields RRS feed

  • Question

  • 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
        CheckCODAmt = bRet
    End Function


    The issue seems to be around the template macro being able to interact with the document that called it.  If I use:


    I get a "No open documents" error


    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?

    Wednesday, June 12, 2013 5:52 PM

All replies

  • See the article "How to validate the contents of a formfield in a Word form” at:


    If the document that is created from the template has access to the template, the macros in the template should be available for use with the document.

    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org

    Thursday, June 13, 2013 9:41 AM