I've got some code that unzips a file (supposedly). The person who
wrote it says that it works fine on his computer. I've seen it work,
too. :) However, I'm running it from my computer and I get an error
message that says "The file exists". Error occurs on this line (Watch
for word wrap):
objShellApp.NameSpace(strWorkFolder).CopyHere
objShellApp.NameSpace(strZipFilePath).Items

Has anybody used the Shell Namespace for unzipping before? And if
sso, would you please point out why this might not work? I'm running
XP Professional with all the latest updates.



Public Sub Extract()

'Declare variables
Dim objFileSystem
Dim workFolder As Folder
Dim workFile As File
Dim objShellApp
Dim strUcaseFileName As String
Dim strZipFilePath, strWorkFolder

'Initialize objects
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set workFolder = objFileSystem.GetFolder(strWorkPath)
Set objShellApp = CreateObject("Shell.Application")

For Each workFile In workFolder.Files
strUcaseFileName = UCase(workFile.Name)
If (Mid(strUcaseFileName, 1, 2) = "PS" Or _
Mid(strUcaseFileName, 1, 3) = "TLD" _
Or Mid(strUcaseFileName, 1, 2) = "RP" Or Right(strUcaseFileName, 4) =
".ZIP") Then
objFileSystem.DeleteFile (strWorkPath & workFile.Name)
End If
Next

'Copy the file with unit extension to work
'directory with the name work.zip
'for processing the zip file. Assign the
'complete path of the file to a variable
objFileSystem.CopyFile strLEWkPath & Infilename, strWorkPath &
"work.zip"

'ShellApp.Namespace is not able
'to accept string type variables.
'hence we are taking a variant type local variables
'to hold work folder path and zip file name and path
strZipFilePath = strWorkPath & "work.zip"
strWorkFolder = strWorkPath & "Extract"
strWorkFolder = strWorkPath

'Use Shell.Application object's "Copyhere"
'method to extract files from the zip file
'this depends on the default file extraction
'capability of windows it works in XP
'********Important*********** This code will not
'work on windows 2000 Pro.
objShellApp.NameSpace(strWorkFolder).CopyHere
objShellApp.NameSpace(strZipFilePath).Items


Set objFileSystem = Nothing
Set objShellApp = Nothing
End Sub

Re: Unzip File by Ayush

Ayush
Wed Feb 28 14:01:00 CST 2007

-------- Original Message --------:
> I've got some code that unzips a file (supposedly). The person who
> wrote it says that it works fine on his computer. I've seen it work,
> too. :) However, I'm running it from my computer and I get an error
> message that says "The file exists". Error occurs on this line (Watch
> for word wrap):
> objShellApp.NameSpace(strWorkFolder).CopyHere
> objShellApp.NameSpace(strZipFilePath).Items

> Has anybody used the Shell Namespace for unzipping before? And if
> sso, would you please point out why this might not work? I'm running
> XP Professional with all the latest updates.


I didn't know that you can do that with zip files but i made this from that
code, see if this works :

copyTo = "C:\Documents and settings\Ayush\Desktop"
zipFile= "E:\Tempp\aicon120.zip"

set sa = CreateObject("Shell.Application")
sa.NameSpace(copyTo).CopyHere(sa.NameSpace(zipFile).items)




Good Luck, Ayush.
--
VBScript Language Reference : http://snipurl.com/VBScript_Reference

Re: Unzip File by Jennifer

Jennifer
Wed Feb 28 14:35:45 CST 2007

On Feb 28, 2:01 pm, Ayush <"ayushmaan.j[aatt]gmail.com"> wrote:
> -------- Original Message --------:
> > I've got some code that unzips a file (supposedly). The person who
> > wrote it says that it works fine on his computer. I've seen it work,
> > too. :) However, I'm running it from my computer and I get an error
> > message that says "The file exists". Error occurs on this line (Watch
> > for word wrap):
> > objShellApp.NameSpace(strWorkFolder).CopyHere
> > objShellApp.NameSpace(strZipFilePath).Items
> > Has anybody used the Shell Namespace for unzipping before? And if
> > sso, would you please point out why this might not work? I'm running
> > XP Professional with all the latest updates.
>
> I didn't know that you can do that with zip files but i made this from that
> code, see if this works :
>
> copyTo = "C:\Documents and settings\Ayush\Desktop"
> zipFile= "E:\Tempp\aicon120.zip"
>
> set sa = CreateObject("Shell.Application")
> sa.NameSpace(copyTo).CopyHere(sa.NameSpace(zipFile).items)
>
> Good Luck, Ayush.
> --
> VBScript Language Reference :http://snipurl.com/VBScript_Reference

Thank you. I get the same error message (The file exists.) And just
on another note, I meant to post this in the VB 6 group. You may have
noticed the declaration of some variables as stings. :) But in any
case, VBScript works as well, since that was where this was modified
from to start with.

Again, thanks.


Re: Unzip File by noone

noone
Mon Mar 05 11:10:04 CST 2007

Il giorno 28 Feb 2007 11:14:22 -0800, "Jennifer" <J.Evans.1970@gmail.com> ha scritto:
>Has anybody used the Shell Namespace for unzipping before? And if
>so, would you please point out why this might not work? I'm running
>XP Professional with all the latest updates.

XP treats zips as directories. I wrote some code to zip files and I realized that
NameSpace wants a complete and correct pathname. Msgbox the pathname before using the
NameSpace to check it. I don't know if spaces in the filename can cause problems.

Giovanni.
--
Giovanni Cenati (Aosta, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--