Error when running Shell32Bit

G

gw.boswell

Group,

I have a macro that calls a DOS program, waits until it has finished
executing, then continues with the macro. I have used this macro for a
couple of years. I have now move to a new machine, running Windows XP,
Service pack 2. Now, the macro no longer runns correctly and generates
the following error message:

"Object library invalid or contains references to definitions that
could not be found."

Here is the partial coded for the macro. This is a piece of code I
copied from one of the programming sites.

Partial code:

Delcarations:
Private Declare Function OpenProcess Lib "kernel32" (ByVal
dwDesiredAccess As Long, ByVal bInheritHandle _
As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal
hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400

Sub Shell32Bit(ByVal JobToDo As String)
Dim hProcess As Long
Dim RetVal As Long

'The next line launches JobToDo and captures process ID
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, True,
Shell(JobToDo, 2))
Do
'Get the status of the process
GetExitCodeProcess hProcess, RetVal
'Sleep command recommended as well as DoEvents
DoEvents: Sleep 100
'Loop while the process is active
Loop While RetVal = STILL_ACTIVE
End Sub

I have searched all the files and have located 2 instances of
"kernel32.lib" and one "kernel32.dll". So it may be that these files
no longer contain the required definitions.

So I again searched for help and located another method to call a DOS
program and wait until it completes before continuing with the macro.
The source of this second method is "Microsoft help and support, How
To Use a 32-Bit Application to Determine When a Shelled Process Ends".
Unfortunately I get the same error message with this code. Can anyone
suggest the source of the problem and more importantly, how to croorect
it?

Garry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top