ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   question regarding unzipping a file (https://www.excelbanter.com/excel-programming/435508-question-regarding-unzipping-file.html)

Gary Keramidas

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



Rick Rothstein

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




Gary Keramidas

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





Dave Peterson

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


All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com