Dec 292017
A macro for MS Word for Windows that allows you to scan an image into a document.
File CALERA.ZIP from The Programmer’s Corner in
Category DeskTop Publishing
A macro for MS Word for Windows that allows you to scan an image into a document.
File Name File Size Zip Size Zip Type
CALERA.DOC 23833 10031 deflated

Download File CALERA.ZIP Here

Contents of the CALERA.DOC file

WordScan/Word for Windows
Scanning and Recognition Macro

By following these instructions, you will complete the installation of Calera's WordScan/Microsoft Word for Windows macro. This macro will add direct scanning and recognition capbilities to Word for Windows.

1.Double-click on the following button:

Macrobutton MakeGlobal Install

2.When the dialog box appears, click to select "ScanIn!", then click OK. Wait while Word for Windows runs the macro.

3.When this document returns to your screen, open the File menu and note that a "Scan..." command has been added.

4.Choose Save All from the File menu. you'll be prompted to "Save global glossary and command changes". Click Yes. If you are prompted to "Save large clipboard, click No (unless you have cut or copied and image to the large clipboard that you want to paste into another application).

Using the Scanning and Recognition Macro

To use the new Scan command, follow these steps:

1.Place your cursor at the point in your text where you want the recognized document to be inserted.

2.Choose Scan from the File menu. A dialog box appears.

3.Choose the desired settings, then click OK to proceed. WordScan operation will proceed as normal, according to the settings you specified above. Refer to the WordScan User's Guide for complete information on using WordScan's features.

Operation proceeds automatically. When recognition (and verification, if applicable) is complete, the recognized text appears in your Word for Windows document, just as though you had typed it!

OIMenuID$&File2** Must be filled in (eng=File, german=Datum, ...)_a/bkmk$A~#i$A"bkmk$iBi;8\selBidefault$Bi&O?{-:g
&Macro to install,eM
X7ScanInMenuID$Scan/OCR... ;9**MacroEdit "ScanIn", 0, "Read text from scanner or file"@byeFOQS
SQ*********************************************************************************\TZ** This is the Word for Windows macro to get text from a scanning device or an image file.[Y** There is nothing magic going on here, but we do rely on some DLL functions supplied bya
_** the Microsoft Windows System. I felt that these were fair to use because WordBasic gives youo** such easy access to them.KI** The way this macro works is to first declare some functions and subs. [Y** Next we use the "USER" function hWnd=GetFocus to find out which window has the focus.6** Now we launch WordScan.fSd** We then want to reactivate ourself with ActivateInputWindow(). This routine resets the focus withKI** SetFocus() and then activates that same window with SetActiveWindow().RP** Now we call DDEInitiate() to establish a communication channel with WordScan.fYd** Word for Windows, in order to maintain control over the macro language, times-out if a DDEExecuteca** command takes too long. As it happens OCR exceeds this limit. Therefore WordScan supports two ]$[** modes of DDE, Standard and Polling. Standard says when you ACK me I will assume you have_]** finished your DDEExecute cmd. Polling on the other hand says when you ACK me I will assumea_** the command has been accepted but not necessarily processed yet. Furthermore I must poll youRDP** with DDERequest commands to find out when you have finished with the command.QO** Polling mode is initiated by a DDEPoke(Chan, "Protocol", "Polling") command.ig** Ok here is the tricky bit. When polling we don't want to eat a bunch of CPU cycles just sitting in aeSc** polling loop. So we set a two second timer and call WaitOnTimer() which is really the "USER" DLLa_** function WaitMessage(). This works nicely because the macro only wakes up every two seconds fd** to see if WordScan is done yet. Otherwise it would be polling many times a second taking CPU awayca** from everyother part of the system. CAUTION: This is what some might call a little too clever.lj** I might agree, but I did determin that there were no ill side effects and found a difinite performance YSW** improvment. Now we just call a bunch of DDEDoCmd() commands. DDEDoCmd() is a controla_** routine for DDEExecute. In WordBasic you must explicitly handle the BUSY flag returned from^\** a DDEExecute command. This is what DDEDoCmd is all about. DDEDoCmd() will trap error 508,`n^** which is DDE Server BUSY, and retry the operation. When the operation has succeded DDEDoCmdfd** will go into its Poll-WaitOnTimer-Loop until the poll indicates the command has been carried out.f6
d** Not much is left but to reactivate ourself and to read in the flawless text supplied by WordScan!Z
X** NOTE: If you wish you may insert your own WordBASIC code at the label "BACKGROUND" ifZ
X** you want to do some type of processing while recognition is running. Just search for:S** "BACKGROUND"e**8j6** Author: Luke Tomasello (Calera Recognition Systems)** Date: Sept. 1, 1990** Change Log:DB** Sep. 29, 1990:Change default file name to four character name.0.** Trap ALL errors, CLEANUP, process error.)C'** Remove "Waiting for Text" message$m"** Add configuration file stuff86** Sep. 30, 1990:Trap error for (Cancel) from dialog.97** Oct. 3, 1990:Change image format to TIFF PackBits.4
2**Display error if WordScan is already running.J:
H** Oct. 4, 1990:Add DDE support for "Get WordScan installed directory"+
)**Rename image from ctxt*.* to cimg*.*G
E**When Renaming old files to new, kill any third generation images<
:**Add version stamp to word for windows macro directoryH6F** Oct. 9, 1990Put main dialog code in new procedure: GetUserRequest86**Always create w4wmacro directory (suspress error)FD**Add image file dialog to Append, Replace or Discard new files.**General code cleanup.FD**Add AppendFiles call to InitTmpFileDir in case old files exist.ScQ** Oct. 17, 1990Add code because WordBASIC does not free LocalHeap allocations HF**when a DDEExecute fails with a BUSY, thus eating Word for Windows=;** LocalHeap. (See the DDERequest("Ready?") call below. T>R**Change DiscardFiles so that it dosn't delete ALL cimg*.* files, just ctxt*.*.ZX** Oct. 22, 1990Fix CleanupFiles routine to check to see if any work needs to be done.GE**Modify MakeGlobal and template to refer to this macro as ScanIn.S6Q*********************************************************************************/0Version$/0MacroDir$/0DefName$
ConfigPreview/0ConfigDotMatrix/0ConfigLandscape/0ConfigImageSource=AIsAppLoadedPKERNELname$4CHGetModuleHandle+6ASetActiveWindowPUSERhWnd4CJoASetTimerPUSERhWnd4CID4CFreq4CProc4D4C/AKillTimerPUSERhWnd4CID4C(!AWaitOnTimerPUSERHWaitMessageYAGetFocusPUSER4C$ASetFocusPUSERhWnd4CMAINOVersion$Version 1.0MacroDir$W4WMACRODefName$CTXT&DefDir$C:\ MacroDir$\HCDeffile$DefDir$ DefName$**Data file location and name DEBUG** Debug varChanTimerID{TimerSet3hWnd GetFocus** Find out who we are;ConfigFile$c:\calmacro.cnf** Configuration file.+ServerName$WordScan** Program nameWYDEBUGlfPreviewKKfOutline`2fFieldCodesh
><** Don't allow a launch of WordScan if it is already running'NIsAppLoadedServerName$
^uServerName$ is already running.j
#Please close WordScan and try again
*bye#!** Find out what user wants to do6GetUserRequest*bye** User cancledG,-*byeZ5\3** Launch ServerName and initiate DDE conversation.%6Loading ServerName$ . . .ServerName$ -DDEActivateInputWindowhWnd%ChanWordScanWordScan!4#2** Get ServerName installed directory (Temp files)XInitTmpFileDirh,-*bye{5}3** Tell WordScan we're going to poll for completion ChanProtocolPolling(&** Set Timer to go off every 2 seconds5TimerSetSetTimerhWndTimerID0TimerSetFTimer not started
c*byenvZxX** Add this code because WordBASIC does not free LocalHeap allocations when a DDEExecute@>** fails with a BUSY, thus eating Word for Windows LocalHeap. Count!ChanReady?noI** Clear the status lineTIFF PackBitsj")]MoDDEDoCmdChan[setoutput(j"Deffile$j")]AConfigVerify DDEDoCmdChan
[proofing(1)]FConfigDotMatrix DDEDoCmdChan[typequality(1)]F5ConfigLandscape DDEDoCmdChan[orientation(1)]HvConfigImageSource DDEDoCmdChan[imagesource(0)]HConfigImageSource DDEDoCmdChan[imagesource(1)]=
ConfigPreview DDEDoCmdChan[preview]:4
DDEDoCmdChan[Scan]jl** Getting the text into WordActivateInputWindowhWnd,*** Insert text at current cursor position.!PDeffile$.DOC
L/~<** = to a carriage return. Automatically converts from RTF.NqDeffile$dlobye0u6,Please wait while ScanIn performs cleanup...\PDeffile$.DOC
WDeffile$.DOC$** Destroys the default scanned fileA Chan
Chan"** This also terminates ServerNameJ[ TimerSet
KillTimerhWndTimerID** Kill The Timer Debug/ KfPreview** Reset the world state$ Old_ViewOutlinefOutline!hfFieldCodes!<&!Err
-Err** Show error if one occured )f!,-*** reset error handler.!CleanupFiles** do file maintenence!Debug
!6Debug version complete!
!6Ok.""""DDEDoCmdChanA$3",-*ErrorTrapM"RetryU"ChanA$k"-m"(* * Start Polling for command completion"Count!"!ChanDone?no+")*****************************************"** BACKGROUND: W
#U** In this loop you may add any macro code you like. This loop executes >= 2 seconds.5e#3** An example of a simple status message is below. <#:** (Marketing made me take this out of the final product!)#**Count = Count + 1&#$**Print "Waiting for text" ; Count+$)*****************************************C$** Clear the status line`$Count6~$CountCount!$** Wait for next timer tick$WaitOnTimer$"$.$ChanDone?yes*Done%%ErrorTrap%Err&%Err)1%6ServerName$ initializing. . .
]%*Retryk% ** Fatal error **7%TimerSet
** CONFIG:&** Byte 1: 1=Scanner, 0=File&** Byte 2: 1=Preview, 0=no&** Byte 3: 1=Verify, 0=no&** Byte 4: 1=DotMatrix, 0=not'** Byte 5: 1=Landscape, 0=not/'**************************L'
N'GetConfig-]'PConfigFile$CreateConfig'=ConfigFile$#74R'S1ConfigImageSource ConfigImageSourceF(S1
ConfigPreviewDG(S1ConfigVerify ConfigVerifyJ(S1ConfigDotMatrix ConfigDotMatrixJ(S1ConfigLandscape ConfigLandscape")N-)6)8)CreateConfigJ)=ConfigFile$#;4(n)610000** Default config)N))
)SetConfig)A$)=ConfigFile$#;4U)ConfigImageSourceA$A$1 A$A$0**Scanner or FileJ<*
ConfigPreviewA$A$1 A$A$0
** PreviewI*ConfigVerifyA$A$1 A$A$0** VreifyN*ConfigDotMatrixA$A$1 A$A$0** DotmatrixN+ConfigLandscapeA$A$1 A$A$0** Landscapeg+6A$v+N++
+GetFileOp+BW,+BH9+O?New_ScaleCoordBWNew_ScaleCoordBHP+g Images already exist.j
Do you want to:!,RopW3,i;New_ScaleCoordBW
!&Replace previously saved images?Pz,iUNew_ScaleCoordBW
&Append to the image list?S,ipNew_ScaleCoordBW
&Discard images just defined?_,eNew_ScaleCoordBW@New_ScaleCoordBHU.-?:-/dlg4?X-?dlgd-GetFileOpdlgopx---*************************-** ReplaceFiles:!-** Delete all old cimg*.* files-** Rename ctxt*.* to cimg*.*-*************************.ReplaceFiles&.** Delete old image files$C.A$PDefDir$cimg*.*
w.WA$.A$P."3..** Rename new image files from ctxt*.* cimg*.*$.A$PDefDir$ctxt*.*
/LDefDir$M/B$DefDir$nA$LIMGnA$LS/:A$4B$d/A$Pu/"|///*************************/** DiscardFiles:"/ ** Delete all new ctxt*.* files./*************************/DiscardFiles0** Delete new image files$$0A$PDefDir$ctxt*.*
** Append:200** Append starts by deleting old ctmp*.* files. 10/** Then we rename all ctxt*.* files to ctmp*.*.G1E** Then we get the first ctmp*.* file and record its page no. Ie "03"R[1P** Then we rename all ctmp-03*.* files back to ctxt-03*.* and call AppendFiles2.614** AppendFiles2 operates on a single page. Eg "03". i1g** AppendFiles2 locates the higest page number so far in the directory then rename/renumbers the files.O2************************j2AppendFiles{2** Delete old temp files$2A$PDefDir$ctmp*.*
2WA$2A$P2"32.** Rename new image files from ctxt*.* ctmp*.*$ 3A$PDefDir$ctxt*.*
T3LDefDir$Mh3B$DefDir$nA$LTMPnA$L3:A$4B$3A$P3"33More3** Get first page number$3A$PDefDir$ctmp*.*4A$*Done444M$ nA$DefDir$/Z4A$PDefDir$ctmp-M$*.*
4LDefDir$M4B$DefDir$nA$LTXTnA$L4:A$4B$4A$P5"5AppendFiles2$5*More05Done75@5B5AppendFiles2#T5** Get higest page no thus farv5high$5A$PDefDir$cimg*.*
:5tempnA$DefDir$$5temphighhightemp6A$P6"66C$khigh#56nC$T6C$0nC$n6 u6C$nC$666C$d6'The macro cannot append pages beyond 99j
*Please enter the file manager and cleanup:j
DefDir$57+=7F7FH7A** Rename and renumber new image files from ctxt-01*.* cimg-02*.*$7A$PDefDir$ctxt*.*
7LDefDir$T7B$DefDir$nA$LIMG-C$nA$L8:A$4B$+8A$P<8"C8L8N8InitTmpFileDir4b8,-&"** we don't want MkDir to complainQ8A$Chanuuiroot+** Always MkDir in case macver was deleted8A$
%9DefDir$A$MacroDir$\%%9DefFile$DefDir$DefName$.F9YlDefDir$DefDir$p9 9w9ServerName$!/macro version mismatch (UUIROOT)9+999** Do version stamp"9=DefDir$MacVer#;4:6Version$:N(:D*:?** Cleanup any ctxt files that may exist from an abnormal abort3m:PDefDir$ctxt*.*
AppendFiles:::**(:&** Find out what the user wants to do:**:GetUserRequest::,-*;';"** Get previous scan configuration8;GetConfigD;=F;8** Start trapping errors. (Cancel) dialog is error #102.;,-*
CheckError;;/STARTSCAN4;O?kk;;eP&LandscapecbLandscape%=hPCSettings==?==** Initialize defaults(>STARTSCANcbVerifyConfigVerify.->STARTSCANcbDotMatrixConfigDotMatrix.W>STARTSCANcbLandscapeConfigLandscape(>STARTSCANoptConfigImageSource*>STARTSCANcbPreview
CheckError?Errf?Err/%?GetUserRequest** user cancledN? #U?GetUserRequest** OKr?{?}?** Reset error handler?,-*?$?** Save this scan configuration(?ConfigVerifySTARTSCANcbVerify.?ConfigDotMatrixSTARTSCANcbDotMatrix.@ConfigLandscapeSTARTSCANcbLandscape(F@ConfigImageSourceSTARTSCANopt*j@
ConfigPreviewSTARTSCANcbPreview@'@"** write this config for next time@SetConfig@@@CleanupFilesG@PDefDir$CIMG*.*
A3ADiscardFilesA1A 4APDefDir$CTXT*.*
BB"Old_ViewOutlinef_Outline f_Outline2 `R[New_ScaleCoordx_*New_ScaleCoordx_




v>"#%-2&78D999c>EEJL}N,QRQwQRRRRR!8"@=Q =QR*R+,MS SerifSymbol"MS Sans Serif
1Courier"Helvetica-Narrow2ModernNewCenturySchlbkRomanTimes New RomanEd=Q3ScanIne9e90K
MakeGlobalLAllows the user to select a macro to be made available in the global contextScanInRead text from scanner or file}}}"
he"%"%&$WordScan Macro Distribution Template"Word for Windows to WordScan MACROCalera,WordScan,OCR,Luke]This document auto-installs the Calera WordScan macro into your Word for Windows environment.Luke S. TomaselloC.J. Johnson

 December 29, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>