S
Sreedhar
Hi,
I've a third party '.exe' file that I'm using to extract zipped files. I've
written a procedure that uses 'Shell and Wait' function found at
http://www.mvps.org/access/api/api0004.htm
Even then, VBA seems to be in a hurry and executing the next line of code
before the shelled program finishes its job. If I'm stepping through, my code
works as expected. Can somebody please help ?
Here's a brief explanation of my code:
Public Function GetFileFromServer(lngFileToExtract As FILE_TO_EXTRACT) As
String
'This function returns full path to a File on the server's hard disk.
Public Function UnZippedFile(strZippedFile As String) As String
'This function accepts the File name (fullpath) returned by the
above function and uses Shell function ('Shell and Wait') to unzip the file
and then returns the full path to the Unzipped file.
Call ShellWait(G_ZIP & " -d " & strLocalCopy, vbNormalFocus)
Public Sub ImportFiles()
'This procedure uses the above functions like this:
CCInput = UnZippedFile(GetFileFromServer(CC_FILE))
KCInput = UnZippedFile(GetFileFromServer(KC_FILE))
When I run the ImportFiles, the code fails at the second line, (i.e. KCInput
= ....... )and the UnzippedFile function fails to unzip the file and returns
an empty string.
And no problems occur when I run the code line by line, pressing F8.
The full code is too long to post to an NG, but if you want to take a look
at it, I don't mind posting the entire module here.
Hope I'm clear enough in explaining the problem.
I've a third party '.exe' file that I'm using to extract zipped files. I've
written a procedure that uses 'Shell and Wait' function found at
http://www.mvps.org/access/api/api0004.htm
Even then, VBA seems to be in a hurry and executing the next line of code
before the shelled program finishes its job. If I'm stepping through, my code
works as expected. Can somebody please help ?
Here's a brief explanation of my code:
Public Function GetFileFromServer(lngFileToExtract As FILE_TO_EXTRACT) As
String
'This function returns full path to a File on the server's hard disk.
Public Function UnZippedFile(strZippedFile As String) As String
'This function accepts the File name (fullpath) returned by the
above function and uses Shell function ('Shell and Wait') to unzip the file
and then returns the full path to the Unzipped file.
Call ShellWait(G_ZIP & " -d " & strLocalCopy, vbNormalFocus)
Public Sub ImportFiles()
'This procedure uses the above functions like this:
CCInput = UnZippedFile(GetFileFromServer(CC_FILE))
KCInput = UnZippedFile(GetFileFromServer(KC_FILE))
When I run the ImportFiles, the code fails at the second line, (i.e. KCInput
= ....... )and the UnzippedFile function fails to unzip the file and returns
an empty string.
And no problems occur when I run the code line by line, pressing F8.
The full code is too long to post to an NG, but if you want to take a look
at it, I don't mind posting the entire module here.
Hope I'm clear enough in explaining the problem.