Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default question regarding unzipping a file

i'm using the shell command to unzip a file. problem is, i need to know when the
file is accessible.
using a loop such as:

Do Until Dir(fpath & "*.dat") < ""
Loop

doesn't really work, because the file exists, but it's not completely unzipped
and is inaccessible. i could use a wait, but every pc is different and i don't
want to use some arbitrary number of seconds.

so, what's the best way to tell when the unzipping procedure is complete?

--


Gary Keramidas
Excel 2003


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default question regarding unzipping a file

This procedure might work for you...

Paste these lines in the (General)(Declarations) section of the code window
where the Shell command is being called from (or remove the Private keywords
and put them in a BAS module if more than one form will use them):

Private Declare Function OpenProcess _
Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle _
Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject _
Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Call your Shell command in this form with the appropriate Shell arguments
placed in the parentheses:

PID = Shell( <<Put Shell Arguments Here )

And finally, paste the following IMMEDIATELY after the PID=Shell statement
above (making sure to handle the possible error where indicated; i.e. stop
the code from falling through to your other commands if the Shell failed):

If PID = 0 Then
'
' Handle Error, Shell Didn't Work
'
Else
hProcess = OpenProcess(&H100000, True, PID)
WaitForSingleObject hProcess, -1
CloseHandle hProcess
End If
'
' Rest of your code goes here
'

--
Rick (MVP - Excel)


"Gary Keramidas" <GKeramidasAtMSN.com wrote in message
...
i'm using the shell command to unzip a file. problem is, i need to know
when the file is accessible.
using a loop such as:

Do Until Dir(fpath & "*.dat") < ""
Loop

doesn't really work, because the file exists, but it's not completely
unzipped and is inaccessible. i could use a wait, but every pc is
different and i don't want to use some arbitrary number of seconds.

so, what's the best way to tell when the unzipping procedure is complete?

--


Gary Keramidas
Excel 2003



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default question regarding unzipping a file

i'll give it a try, thanks rick.

--


Gary Keramidas
Excel 2003


"Rick Rothstein" wrote in message
...
This procedure might work for you...

Paste these lines in the (General)(Declarations) section of the code window
where the Shell command is being called from (or remove the Private keywords
and put them in a BAS module if more than one form will use them):

Private Declare Function OpenProcess _
Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle _
Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject _
Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Call your Shell command in this form with the appropriate Shell arguments
placed in the parentheses:

PID = Shell( <<Put Shell Arguments Here )

And finally, paste the following IMMEDIATELY after the PID=Shell statement
above (making sure to handle the possible error where indicated; i.e. stop the
code from falling through to your other commands if the Shell failed):

If PID = 0 Then
'
' Handle Error, Shell Didn't Work
'
Else
hProcess = OpenProcess(&H100000, True, PID)
WaitForSingleObject hProcess, -1
CloseHandle hProcess
End If
'
' Rest of your code goes here
'

--
Rick (MVP - Excel)


"Gary Keramidas" <GKeramidasAtMSN.com wrote in message
...
i'm using the shell command to unzip a file. problem is, i need to know when
the file is accessible.
using a loop such as:

Do Until Dir(fpath & "*.dat") < ""
Loop

doesn't really work, because the file exists, but it's not completely
unzipped and is inaccessible. i could use a wait, but every pc is different
and i don't want to use some arbitrary number of seconds.

so, what's the best way to tell when the unzipping procedure is complete?

--


Gary Keramidas
Excel 2003




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default question regarding unzipping a file

Ron de Bruin has lots of code samples for working with zip files:
http://www.rondebruin.nl/tips.htm
look for zip

Gary Keramidas wrote:

i'm using the shell command to unzip a file. problem is, i need to know when the
file is accessible.
using a loop such as:

Do Until Dir(fpath & "*.dat") < ""
Loop

doesn't really work, because the file exists, but it's not completely unzipped
and is inaccessible. i could use a wait, but every pc is different and i don't
want to use some arbitrary number of seconds.

so, what's the best way to tell when the unzipping procedure is complete?

--

Gary Keramidas
Excel 2003


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hello everybody.. question about .csv file... yakir Excel Discussion (Misc queries) 3 May 24th 10 06:11 PM
unzipping files GEORGIA Excel Programming 10 August 8th 05 03:49 PM
sdv file question Ruben Mikkelsen Excel Programming 5 January 9th 05 07:30 PM
unzipping a file MarkS[_2_] Excel Programming 1 December 4th 03 11:03 PM
End of File Question dayton Excel Programming 1 September 8th 03 06:58 PM


All times are GMT +1. The time now is 03:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"