Consulting

Results 1 to 3 of 3

Thread: Solved: copyhere method

  1. #1
    VBAX Regular
    Joined
    Mar 2009
    Posts
    37
    Location

    Solved: copyhere method

    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
    [vba]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)[/vba]
    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
    [vba]oApp.Namespace(DFTArchiveFolder & fnm).CopyHere (fileNameInZip) FOF_NONCONFIRMATION[/vba]

    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?

  2. #2
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Maybe check to see if the unzip file name exists before you unzip and if it does Kill it? Dave

  3. #3
    VBAX Regular
    Joined
    Mar 2009
    Posts
    37
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •