DocContent and DocWord example 1

The following code illustrates how to use the DocContent and DocWord objects.

This is a simple example of form classification: There are three different forms without any adjustment fields. The only thing that identifies them is the strings "1234" (FormDefA), "6789" (FormDefB), and "ABCD" (FormDefC) in random positions. The VBA code calls Job.AddExternalValidFormDef when an ID is found. This makes the job select only one of the form definitions during identification. AddExternalValidFormDef selects which one of these is actually valid.

Note that the job must contain all the form definitions.

 

Function OnJobFormIdentify(FrontPgTiff As String, BackPgTiff As String) As Long

    Dim DocCont As Object

    Dim Wrd As Object

    Dim ValStr As String

 

    Set DocCont = Application.FindAllObjects(0)

    DocCont.InterpretAllWords

 

    Set Wrd = DocCont.GetFirstWord()

    Do While Not (Wrd Is Nothing)

        ValStr = Wrd.GetValueStr()

        MsgBox "Word " & i & ": " & ValStr

        If ValStr = "1234" Then

        Application.Job.AddExternalValidFormDef ("FormDefA")

        Exit Do

    ElseIf ValStr = "6789" Then

          Application.Job.AddExternalValidFormDef ("FormDefB")

        Exit Do

    ElseIf ValStr = "ABCD" Then

                 Application.Job.AddExternalValidFormDef ("FormDefC")

              Exit Do

           End If

        Set Wrd = DocCont.GetNextWord()

    Loop

OnJobFormIdentify = EV_OK    ' Return value to FORMS

End Function