Generation by software – Kofax DOKuStar Validation User Manual

Page 19

Advertising
background image

DOKuStar Validation Programming Manual

Page

15

Generation by Software

What we just did interactively can also be done through software, either in the VBA studio, or from the outside via
the COM interface. We will do it now in Microsoft Visual Basic, expanding the small piece of code we had above
(the VBA variant will be discussed later):

Private Sub Form_Load()
Dim MyApp As New DOKuStarDataset.Application '* declare dataset part of
DOKuStarValidation

'* make sure no project is open
If Not MyApp.Project Is Nothing Then
MyApp.Project.Close
End If

'* create the Project and fill the schema
MyApp.CreateProject
fillSchema MyApp.Project.DataSet.schema
'* save the project in application path
MyApp.Project.SaveAs App.Path + "\MyProject.vpj"
MyApp.Quit
Unload Me
End Sub

'*
'*** subroutine to define the schema
'*
Private Sub fillSchema(schema As DataSchema)
Dim docTypeLetter As DocumentType
Dim docTypeInvoice As DocumentType
Dim docTypeVoucher As DocumentType
Dim docTypeCovering As DocumentType
Dim fld As FieldType
Dim docDescLetter As DocumentDescriptor

'* first, define the DocumentTypes
Set docTypeLetter = schema.DocumentTypes.Add("Letter") ' add the "Letter" document type
docTypeLetter.FieldTypes.Add "TextField", "Sender" ' add the "Sender" field as TextField

Set docTypeInvoice = schema.DocumentTypes.Add("Invoice") ' add the "Invoice" document type
Set fld = docTypeInvoice.FieldTypes.Add("TextField", "TotalAmount") ' add a TextField
Set fld = docTypeInvoice.FieldTypes.Add("TextField", "InvoiceDate") ' add a TextField
Set fld = docTypeInvoice.FieldTypes.Add("TableField", "Details") ' add a TableField
fld.FieldTypes.Add "TextField", "Quantity" ' add a column
fld.FieldTypes.Add "TextField", "SinglePrice" ' add a column
fld.FieldTypes.Add "TextField", "TotalPrice" ' add a column

Set docTypeVoucher = schema.DocumentTypes.Add("Voucher") ' add the "Voucher" document type
docTypeVoucher.FieldTypes.Add "TextField", "VoucherDate" ' add the "VoucherDate" field as
TextField

Set docTypeCovering = schema.DocumentTypes.Add("CoveringLetter") ' add the "CoveringLetter"
document type

'* second, define the DocumentModel
Set docDescLetter = schema.DocumentModel.DocumentDescriptors.Add(docTypeLetter)
docDescLetter.Descriptors.Add docTypeCovering ' add the subdocument
docDescLetter.Descriptors.Add "Invoice" ' alternative: add a subdocument by name
docDescLetter.Descriptors.Add docTypeVoucher
End Sub

Advertising