AutoTrim example for Access 95 and 97

This example scans a document and trims the edges.

'Declare local variables.
Dim SavedSetting, nRet, X, CalcHeight

'Make sure display rectangles are reset when we acquire the image.
Lead1.AutoSetRects = True

'Disable automatic repainting.
Lead1.AutoRepaint = False

'Acquire the image, allowing for possible mistakes.
SavedSetting = Lead1.EnableMethodErrors
Lead1.EnableMethodErrors = False
nRet = Lead1.Load(“d:\temp\test.tif”, 0, 1, 1)
If nRet <> 0 Then
    MsgBox "image not loaded"
    Lead1.EnableMethodErrors = SavedSetting
    GoTo FINISHED
End If
Lead1.EnableMethodErrors = SavedSetting

'Trim the edges of the acquired bitmap.
Lead1.AutoTrim (64)

'Use most of the window.
X = Me![Lead1].Section
Me![Lead1].Top = Me.Section(X).Height * 0.1
Me![Lead1].Left = Me.Width * 0.1
Me![Lead1].Width = Me.Width * 0.8
Me![Lead1].Height = Me.Section(X).Height * 0.8

'Set up for good display of a typical scanned document.
Lead1.BitonalScaling = BITONALSCALING_SCALETOGRAY
Lead1.AutoScroll = True
Lead1.DstWidth = Lead1.ScaleWidth 'Use the full control width.
Lead1.DstClipWidth = Lead1.ScaleWidth
CalcHeight = (Lead1.BitmapHeight * Lead1.ScaleWidth) / Lead1.BitmapWidth
Lead1.DstHeight = CalcHeight 'Use the proportional height.
Lead1.DstClipHeight = CalcHeight

'Enable automatic repainting.
Lead1.AutoRepaint = True
FINISHED: