Page 1 of 1

Preview current scan before saving

Posted: Thu Feb 05, 2015 8:48 pm
by jheilman
Hello All,

Is it possible to preview the scanned document in the image1.Picture before saving? I've been successful at scanning and saving to a folder on the server. When I navigate record to record the images do load correctly.

I would like to scan the image, display it before saving on the form, and then have the user continue by clicking "Save" or cancel.

Here is what I have so far:

Code: Select all

'Scan Button

Private Sub BAcquire_Click()

Dim User As String
Dim Email As String
Dim RegCode As String
Dim Result As Long

   
    VSTwain1.StartDevice
         If VSTwain1.SelectSource = 1 Then
            VSTwain1.autoCleanBuffer = 1
            VSTwain1.maxImages = 1
            VSTwain1.showUI = 1
            VSTwain1.Acquire
        End If

'Set Image1.Picture = VSTwain1.GetCurrentImage <<<<< I haven't been able to get this to work.  I get an "Invalid Use of Property" error.
           
 End Sub

'Save Button

Private Sub SaveScan_Click()
Dim flag As Long
Dim strFileName As String

 strFileName = Me.txtstrFileName

    If flag <> 0 Then
        If VSTwain1.errorCode <> 0 Then
            MsgBox VSTwain1.ErrorString
        End If
    Else
               
          VSTwain1.TiffCompression = 1
          If (VSTwain1.SaveImage(0, "q:\Downstream\" & strFileName) = 1) Then
          MsgBox VSTwain1.ErrorString
          End If
            
      '      Dim fName As String
       '     fName = "Q:\Downstream\" + Me!strFileName
        '    VSTwain1.SaveImage 0, fName
                    
         '  If VSTwain1.errorCode <> 0 Then
          '      MsgBox VSTwain1.ErrorString
           ' Else
            '    Me![Link] = fName
             '   Me![Image1].Picture = fName
            End If
        'End If
    'End If
    Me.Image1.Requery
    
End Sub

Re: Preview current scan before saving

Posted: Fri Feb 06, 2015 11:34 am
by Alex
Hello,

You have the problem because the VSTwain.Acquire method is asynchronous method - it just starts the asynchronous image acquisition process. You need preview/save image in the handler of the VSTwain.PostScan event.

Also you can use the VSTwain.AcquireModal method instead of the VSTwain.Acquire method.

Best regards, Alexander