This example uses SetScanCapability to specify the Image Type for scanning, without using the scanner's TWAIN dialog box.
Private Sub CmdSetImgType_Click() 'User is given the option to select an Image Type for scanning 'of black and white, grayscale or color. The option selected 'is stored in the global variable ScanType. Const IT
_BW = 1
Const IT
_GRAY8 = 4
Const IT
_RGB = 16
Const CAP
_SCAN
_IMAGE
_TYPE = 100
Const CAP
_SCAN
_IMAGE
_TYPES
_SUPPORTED = 1
Dim varScanImgType As Variant
'Global Scantype as integer
'Scanner must be open for Capability check.
ImgScan1.OpenScanner
'See what image types the scanner supports.
varScanImgType = ImgScan1.GetScanCapability(CAP
_SCAN
_IMAGE
_TYPES
_SUPPORTED)
If VarType(varScanImgType) = vbError Then
MsgBox "Unable to get Supported Image Types"
End If
'Find out if the type the user selected is supported. 'if so set the capability to that image type
Select Case ScanType
Case 1
If varScanImgType And IT
_BW Then
ImgScan1.SetScanCapability CAP
_SCAN
_IMAGE
_TYPE, IT
_BW
Else
MsgBox "Black & White image type is not supported by your scanner"
End If
Case 2
If varScanImgType And IT
_GRAY8 Then
ImgScan1.SetScanCapability CAP
_SCAN
_IMAGE
_TYPE, IT
_GRAY8
Else
MsgBox "Grayscale image type is not supported by your scanner"
End If
Case 3
If varScanImgType And IT
_RGB Then
ImgScan1.SetScanCapability CAP
_SCAN
_IMAGE
_TYPE, IT
_RGB
Else
MsgBox "Color image type is not supported by your scanner"
End If
End Select
End Sub