See Also Examples Applies To
This opens the source selected in the Select Source dialog.
If some source is already open, does nothing and returns TRUE.
First call this function for each scanning process or to set the TWAIN state to 4 (TWAIN_SOURCE_OPEN) when the TWAIN state is
3 (TWAIN_SM_OPEN) or 2 (TWAIN_SM_LOADED) or 1 (TWAIN_PRESESSION).
Syntax
object.TwainOpenDefaultSource ()
The TwainOpenDefaultSource syntax has these parts:
| Part | Description |
| object | Required. An object expression that evaluates to an object in the Applies To list. |
Returns
Boolean. True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode() functions for diagnosing the error.
Remarks
If this call returns TRUE, TWAIN is in STATE 4 (TWAIN_SOURCE_OPEN).
Category
TWAIN Functions
Visual Basic Sample
Acquire multiple image from the document feeder to a multipage PDF
Dim nImageID As Long
Object.TwainOpenDefaultSource
Object.TwainSetAutoFeed (True) 'Enable AutoFeed
Object.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
Object.TwainSetCurrentPixelType (TWPT_RGB) '24 bit color image
Object.TwainEnableDuplex (True) 'Duplex acquisition if supported
Object.TwainSetHideUI (True) 'Asks to the device to hide his GUI
Call Object.TwainPdfStartEx("acquire.pdf", "PdfTitle", "PdfCreator", "PdfAuthor", "PdfProducer")
Do
nImageID = Object.TwainAcquireToGdPictureImage(Me.hwnd)
If nImageID <> 0 Then
Object.TwainAddGdPictureImageToPdf (nImageID)
Object.CloseImage (nImageID)
End If
Loop While Object.TwainGetState() > 5
Object.TwainPdfStop
Object.TwainCloseSource
Acquire multiple image from the document feeder to a multipage tif image
Dim nImageID As Long
Dim nImageCount As Long
Object.TwainOpenDefaultSource
Object.TwainSetAutoFeed (True) 'Enable AutoFeed
Object.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
Object.TwainSetCurrentPixelType (TWPT_BW) '1 bit bw image
Object.TwainEnableDuplex (True) 'Duplex acquisition if supported
Object.TwainSetHideUI (True) 'Asks to the device to hide his GUI
nImageCount = 0
Do
nImageID = Object.TwainAcquireToGdPictureImage(Me.hwnd)
If nImageID <> 0 Then
nImageCount = nImageCount + 1
If nImageCount = 1 Then
Call Object.TiffSaveAsNativeMultiPage("acquire.tif", CompressionCCITT4)
Else
Object.TiffAddToNativeMultiPage (nImageID)
End If
Object.CloseImage (nImageID)
End If
Loop While Object.TwainGetState() > 5
Object.TiffCloseNativeMultiPage
Object.TwainCloseSource