Solved

Using command lines to operate OCR software through VB6

Posted on 2003-11-26
4
978 Views
Last Modified: 2008-02-26
Hi

I'm having real difficulty with using command lines to control a OCR program through Visual Basic 6.

Basically I have command lines to control a OCR program called SimpleOCR, and honestly I have no Idea how!!

So far I've tried running through DOS with very little luck.
Is there an easier way to use these command lines to access my OCR software.

Thanking in advance
0
Comment
Question by:Reachtabhair
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9825046
Hi Reachtabhair,
Dim RetVal
RetVal = Shell("pathtocommandlinecommand.EXE", 1)   ' Run command.

However, this will start the command, but not wait for it to finish.

For more subtle control, you'll have to look into the ShellExecute or ShellExecuteEX API.

Regards .. Alan
0
 

Author Comment

by:Reachtabhair
ID: 9831316
Hi alan
thanks for the reply

This is what i've done so far, the problem is that I keep getting a error called 'File Creation Error' on the DOS screen.

If you could have a look at the code and give me your opnion it would be greatly appreciated....


Private Sub Command1_Click()
    Open "C:\commandline.bat" For Output As #1
    Print #1, "Cd .."
    Print #1, "Cd .."
    Print #1, "Cd .."
    Print #1, "Cd .."
    Print #1, "cd progra~1"
    Print #1, "cd Simple~1"
    Print #1, "cd bin"
    Print #1, "simpleocrcmd"
    Print #1, "SimpleOCRCmd [/NONE] <C:\images\Test.tif> <C:\text\line.txt>"
    Close #1
   
    Shell ("C:\commandline.bat"), vbNormalFocus
End Sub


0
 
LVL 10

Accepted Solution

by:
ADSaunders earned 125 total points
ID: 9831394
Hi,
If this text is verbatim, then your problems are with the '<' and '>'  characters on the command line. Dos and up uses these as redirection commands viz a < b    means 'run a taking it's input from b, and a > c means run a sending output to c
so the file creation error is probably fom the '.tif> <C' in the command line or the > at the end.
In any case, is it really necessary to create a batch file, I would have thought that:

Shell ("\progra~1\Simple~1\bin\SimpleOCRCmd /NONE C:\images\Test.tif C:\text\line.txt",vbNormalFocus)

Would have done

.. Alan
0
 

Author Comment

by:Reachtabhair
ID: 9832448
Thanks a milion Alan

Gary
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question