Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Shell 1

Status
Not open for further replies.

toccata

Programmer
Jun 26, 2002
65
US
I am attempting to get an external call to halt before continuing with succeeding code.

I attempted to adapt CajunCenturian's module Thread705-667547 to my code that calls the Crystal Print Engine, without success - certainly my own ignorance. My call to the CPE:

Dim stAppName As String

stAppName = "C:\WinTBM\rptInvoiceRegister.exe"
Call Shell(stAppName, 1)

The engine runs fine, but succeeding msgbox appears before the engine exits and returns.

Any suggestions?
 
Try this.


(declarations)

Declare Function GetModuleUsage Lib "Kernel" (ByVal hModule As Integer) As Integer

(somewhere within a module)
Dim hModule as Integer
Dim stAppName As String

stAppName = "C:\WinTBM\rptInvoiceRegister.exe"

hModule = Shell(stAppName,1)
Do While GetModuleUsage(hModule)
DoEvents
Loop
DoCmd Echo True, "Report Completed"


The DoEvents should let the Shell call complete before continuing with the rest of your code.


Hope this helps you out.


Steve
 
The code that I posted does not use the Shell command. The Shell command, as you're using in your original will always run asynchronously.

I'd be more than happy to try and help with the adapdations that you'd like to make to get the working.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks all...

I need a method that will call the executable and wait until completion before returning to succeeding code. My system has several hundred of these calls for various compiled Crystal Reports imbedded in many layers of open forms. I tried the MS link from p27br which executed fine from a single form, but caused chaos when executed inside the many layers of forms in my project.

I will persevere.
 
The method that I posted in the thread you previously referenced will call the executable and wait until completion.

You said that you tried to adapt that code, but were having difficulties. If you post the adaptations of the code from the other thread, and a brief description of the difficulties, then perhaps we can work this out.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top