PDA

View Full Version : Solved: copyhere method



mugcy
06-30-2009, 02:48 AM
Hi,

I've been writing some code on Excell VBA to copy particular file from a zip folder to a new folder using the following code bit
Set oApp = CreateObject("Shell.Application")
For Each fileNameInZip In oApp.Namespace(zipObj).items

zipExt = Right(fileNameInZip, 3)


Zipfilename = Mainfilename(fileNameInZip)
If Zipfilename Like DFTFile Then
'Copy the DFT file to DFT Files Folder
oApp.Namespace(FileNameFolder).CopyHere (fileNameInZip)
'Rename the DFT file as TXT file
'Name FileNameFolder & fileNameInZ being copied alreadyip As FileNameFolder & DFTFile & ".txt"
'Copy the DFT file to the Archive Folder
oApp.Namespace(DFTArchiveFolder & fnm).CopyHere (fileNameInZip)
End If
Next
'Delete the store zip file from ZIP files folder
Kill (zipObj)
sometimes the new folder has the files with the same file name that are extracted from the zip file. I need these files to overwrite the existing files without pressing "yes to All".

I tried using
oApp.Namespace(DFTArchiveFolder & fnm).CopyHere (fileNameInZip) FOF_NONCONFIRMATION

with FOF_NONCONFIRMATION defined as a constant 16. But still it keeps asking for input to overwrite.


can someone pls help me to fix this?

Dave
06-30-2009, 10:21 PM
Maybe check to see if the unzip file name exists before you unzip and if it does Kill it? Dave

mugcy
07-01-2009, 03:26 AM
With some research I found out that the options in the copyhere method dosen't work when unziping files. As a workaround files have to be unzipped to a TEMP folder and then copy them to the destination folder using copyhere.file, NONconfirmation.


Anyway Thank you very much for your help Dave:thumb:friends::hi: