VBA复制和replacezip文件夹中的文件

我已经创build了一个VBAmacros,它根据许多参数从文件夹/子文件夹中提取文件。 这包括查找符合这些参数的zip文件夹并将其复制到新目录,以便每个文件都可以通过search。 我遇到的问题是,这些zip文件中的许多文件都是重复的,并且项目要自动化,所以我不能坐在那里,每次popup时都不要复制button。 有没有办法通过zip文件search并忽略重复的文件? 我的代码的这一部分是:

Sub Unzip(fileName As String, mainSubfolder As String) Dim sourceDir As String, fileString As String Dim FileNameFolder As Variant Dim oApp As Object sourceDir = "\\Filesrv02\depts\AR\EDIfiles\Remits" fileString = mainSubfolder + fileName If Right(sourceDir, 1) <> "\" Then sourceDir = sourceDir & "\" End If FileNameFolder = sourceDir & "Unzipped" If Dir(FileNameFolder, vbDirectory) = vbNullString Then MkDir FileNameFolder End If Set oApp = CreateObject("Shell.Application") oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(fileString).Items End Sub 

最后两行是将zip文件夹中的文件复制到名为“Unzipped”的新文件夹中的位置。 但是,我不知道如何得到zip文件夹中的每个单独的文件来说明它是否已经存在,忽略它。 任何build议将不胜感激!

也许这有助于:(取自: https : //stackoverflow.com/a/14987890/3883521 )

 With oApp.NameSpace(ZipFile & "\") If OverwriteFile Then For Each fil In .Items If FSO.FileExists(DefPath & fil.Name) Then Kill DefPath & fil.Name End If Next End If oApp.NameSpace(CVar(DefPath)).CopyHere .Items End With