Integra for Notes Banner
  QuickReports Integra4Notes Integra Family of Products



Importing MS-Word Document fields other then the ones of type Mailmerge

Integra for Notes provides a facility to automate the importation of Word documents into a Lotus Notes database. The Import feature allows to import the contents of the Word document either as embedded object, attachment or Notes richtext. It is also possible to import the meta data (Word document properties, such as the document title, author, date of creation, etc.) and any Word Mailmerge field contained with in the Word document into fields of the new created Notes document. All this is documented in the user manual.

Integra for Notes, however, does not support the import of fields contained in the Word document that are not of type Mailmerge, e.g. fields of type Fillin. The following example shows how to import not supported Word field types using the right configuration in the Fields tab of the Integra profile and using the further down listed Lotus Script code in the Callback Script field of the Advanced tab.

Scenario

Word document based on a particular Word template are to be imported into a slightly customised Notes Microsoft Office Library. The customisation consists of a subform included in the main document form that contains a number of fields to receive the Fillin field information of the Word documents. Besides importing these Fillin fields into the Notes document, it is required to store the Word contents complete in a Notes richtext field and also to receive some of the Word document properties.

The following screen shot shows the fields to be imported.


The fields Number, ReferenceSign, PhoneExtention & FileReference are referring to Fillin fields in the Word document. The Body field is to receive the Word document contents as Notes richt text and all other fields refer to Word document properties. In Integra for Notes 4.0 the Word document contents as well as all the Document properties are exposed in the profile interface and can easily be selected and added to the Selected Field List. The fields referring to the Word Fillin fields are to be added as computed fields (see screen shot below).


The following table shows the formulas to each of the fields in the Selected Field List:

FIELDNAMEFORMULAREMARKS
NUMBER"WORD.FILLIN.NUMMER"to be entered
REFERENCESIGN"WORD.FILLIN.REFERENCESIGN"to be entered
BODY"WORD.RICHTEXT"system generated
COMPOSEDDATE"WORD.PROPERTIES.CREATED"system generated
FROM"WORD.PROPERTIES.AUTHOR"system generated
LASTEDITOR"WORD.PROPERTIES.LASTAUTHOR"system generated
LASTEDIT"WORD.PROPERTIES.TIMELASTSAVED"system generated
NUMPAGES"WORD.PROPERTIES.PAGES"system generated
CATEGORY"WORD.PROPERTIES.CATEGORY"system generated
SUBJECT"WORD.PROPERTIES.SUBJECT"system generated
PHONEEXTENTION"WORD.FILLIN.PHONEEXTENTION"to be entered
FILEREFERENCE"WORD.FILLIN.FILEREFERENCE"to be entered

Note: Word Fillin fields do not have a fieldname or tagname. The only way to identify a Fillin field is by a unique keyword that is used within the Fillin fields prompt that explains the user what to enter. The following screen shot shows a Word template used for this import. Each Fillin field's prompt contains the keyword used in the field formula, e.g. {FILLIN "Please enter the ReferenceSign"} as in "WORD.FILLIN.REFERENCESIGN".


Last but not least, we need some lines of Lotus Script code to be placed into the Callback Script field in the Advanced tab of the Integra profile. This as Integra will ignore the formulas with the "WORD.FILLIN.xxx" in that it does not further process the result. Without the additional code, the formulas will be evaluated and the return value (e.g. "WORD.FILLIN.NUMBER" -> WORD.FILLIN.NUMBER) assigned as values to the new Notes fields, which of course is not the desired result.

Const CB_INITIALISE      = 3
Const CB_BFORREADCOM     = 7
Const CB_AFTERWRITENOTES = 2
Const CB_TERMINATE       = 4

select case stats.cbstatus
case CB_INITIALISE
case CB_BFORREADCOM
case CB_AFTERWRITENOTES
    Dim wfd  As Long
    Dim lbnd As Long
    Dim ubnd As Long
    Dim pidx As Long
    Dim rslt As Variant
    Dim rstr As String
    Dim fds  As Variant
    lbnd = Lbound(import.Record.Structure.FName)
    ubnd = Ubound(import.Record.Structure.FName)
    For wfd = lbnd To ubnd
      rslt = EvaluateFormula(import.Record.Structure.FMacr(wfd),stats.impdoc)
      rstr = Format(rslt)
      If Left(Ucase(rstr),12) = "WORD.FILLIN." Then
        rstr = Trim(Mid(Ucase(rstr),13))
        Set fds = stats.WordDoc.Fields
        For pidx = 1 To fds.Count
          If Instr(Ucase(fds(pidx).Code.Text),"FILLIN ") = 0 Then
          ElseIf Instr(Ucase(fds(pidx).Code.Text),rstr) = 0 Then
          Else
            call stats.impdoc.ReplaceItemValue(_
                  import.Record.Structure.FName(wfd),_
                  Trim(fds(pidx).Result.Text))  
            Exit For
          End If
        Next
      End If
    Next
    call stats.impdoc.save(true,false,true)
case CB_TERMINATE
end select

Note: Word documents have a quite complex structure. As a result fields can be linked to the main Word object, to Word headers and footers and or to different sections of the Word document (just to name the most obvious places where to look for). The above code searches only the main part of the document for Fillin fields. If you intent to use this example for Word documents that are complex in structure, you need to amend the above code accordingly.

Of course the above example can equally be used to import other types of Word document fields. In which case the Notes formula structure could look like this:

"WORD.ASK.NAMEBOOKMARK"

and the Word fieldname is created as seen in the screen shot below. Of course the script code above needs to be amended accordingly.


Note: Ask fields do have bookmark names that can be referred to. Ask fields are therefore easier to address then Fillin fields

.




FAQ# 0069
Bookmark and Share

 
QUICK LINKS
 
 

 

  © Shireburn Software Ltd. 2008 - 2024