Shell and Wait

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.
 
T

Tony Toews [MVP]

Sreedhar said:
I've a third party '.exe' file that I'm using to extract zipped files.

Try the free open source Info-zip dlls instead of depending on an exe
and shelling.

Compression DLLs, OCXs, etc
http://www.granite.ab.ca/access/compression.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
S

Sreedhar

Tony Toews said:
Try the free open source Info-zip dlls instead of depending on an exe
and shelling.

The text files are in the "*.txt.gz" file format. The links you've given are
useful, but not with these files (?). I don't know much about Files and
Compression, hence the easy and only known (to me) solution of an exe that
I've seen working.

If there are any tools like this which can extract files with such an
extension, please help me know it. Mean while, I will also google for it.

Thanks for opening up the alternatives.
 
T

Tony Toews [MVP]

Sreedhar said:
The text files are in the "*.txt.gz" file format. The links you've given are
useful, but not with these files (?).

Good reason.
If there are any tools like this which can extract files with such an
extension, please help me know it. Mean while, I will also google for it.

Try zlib http://www.zlib.net/ That page mentions both .gz files and
Visual Basic I've added that as a link to my page.

Thanks, Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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