Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
hello everybody.. question about .csv file... | Excel Discussion (Misc queries) | |||
unzipping files | Excel Programming | |||
sdv file question | Excel Programming | |||
unzipping a file | Excel Programming | |||
End of File Question | Excel Programming |