直接上代码
Sub UnZip(ByVal myZipFile, ByVal myTargetDir)Set fso = CreateObject("Scripting.FileSystemObject")If NOT fso.FileExists(myZipFile) ThenExit SubElseIf fso.GetExtensionName(myZipFile) <> "zip" ThenExit SubElseIf NOT fso.FolderExists(myTargetDir) Thenfso.CreateFolder(myTargetDir)End IfSet objShell = CreateObject("Shell.Application")Set objSource = objShell.NameSpace(myZipFile)Set objFolderItem = objSource.Items()Set objTarget = objShell.NameSpace(myTargetDir)intOptions = 256objTarget.CopyHere objFolderItem, intOptions
End Sub
UnZip "C:\Users\Desktop.zip","C:\Users\Desktop\2"