Creating a Script for Document Export

The following script writes classified images to subdirectories in the export directory. Each subdirectory holds documents from one class only; the subdirectory name corresponds to the class name. To create the script, complete the following steps.

  1. In Designer, switch to Definition Mode.
  2. On the toolbar, click Show/hide script .
  3. In the Script View for Project dialog box, from the Object list, select ScriptModule.
  4. From the Proc list, select ExportDocument.
    Note: This generates the outline of a subroutine.
  5. Add the following code.
    Dim sNewPath as String
    Dim MyImage as SCBCroImage
    Dim NewFileName as String
    sNewPath=ExportPath & "\" & pWorkdoc.DocClassName  'Set directory name
    Set MyImage=pWorkdoc.Image(0)  'Access the image file to the current WorkDoc
    On Error GoTo Skip  'Skip next step if directory exists
    MkDir sNewPath      'Create directory
    Skip:
    NewFileName=Mid(MyImage.Filename,  InStrRev(MyImage.Filename,"\")) 'Set file name
    MyImage.SaveFile sNewPath & NewFileName 'Save file to directory
  6. Close the dialog box.
  7. Switch to Runtime Mode and test the script.