ScanTo Example VB

This code segment scans all pages in the ADF to a multipage file while displaying each page.

Private Sub cmdDisplayAndFile_Click()
    ImgScan1.ScanTo = DisplayAndFile
    'Set the image property to a file name.
    ImgScan1.Image = "D:\image2\newpages.tif"
    'Multipage must be true in order to create files with
    'more than one page.
    ImgScan1.MultiPage = True
    'Do not show the scanner's TWAIN UI.
    ImgScan1.ShowSetupBeforeScan = False
    'Scan without using dialog box.
    ImgScan1.StartScan
End Sub

The following two examples demonstrate how the ScanTo property can be used to specify the destination of the image that is being scanned. In the first example, the image is scanned to the file specified by the Image property. In the second example, the image is scanned to the display and to a filename template specified with the Image property.

Note: You should set the Image property after you set the ScanTo property.

'Example 1
Private Sub cmdScanToFile_Click()
    On Error GoTo ScanError    
    ImgScan1.ScanTo = FileOnly      'Scan to a file
    ImgScan1.Image = "c:\scan.tif"  'Destination file
    ImgScan1.StartScan    
    Exit Sub
    
ScanError:
    MsgBox Err.Description, , "Scan Error"
    Exit Sub
End Sub

'Example 2
Private Sub cmdScanToDisplay_Click()
    On Error GoTo ScanError    
    ImgScan1.ScanTo = DisplayAndUseFileTemplate   'Scan to display and template
    ImgScan1.Image = "c:\img"                     'Template = imgxxxxx.tif
    ImgScan1.StartScan
    Exit Sub

ScanError:
    MsgBox Err.Description, , "Scan Error"
    Exit Sub
End Sub