Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ezhov-da/8773d1749c39aabeccc6e5a1f6f4c9b5 to your computer and use it in GitHub Desktop.
Save ezhov-da/8773d1749c39aabeccc6e5a1f6f4c9b5 to your computer and use it in GitHub Desktop.
vba разархивирование файла.vba
Function UnZip_File(ByVal FileNameZip, ByVal DestinationFolder, _
Optional ByVal DeleteSourceFile As Boolean = False) As Boolean
On Error Resume Next: Err.Clear
If Right(DestinationFolder, 1) <> "\" Then DestinationFolder = DestinationFolder & "\"
MkDir DestinationFolder
If Len(Dir(DestinationFolder, vbDirectory)) = 0 Then Exit Function
If Len(Dir(FileNameZip)) = 0 Then MsgBox "Файл """ & FileNameZip & """ не найден", _
vbCritical, "Ошибка в функции UnZip_File": Exit Function
Set oApp = CreateObject("Shell.Application")
For Each it In oApp.Namespace(FileNameZip).Items: Debug.Print it: Next
oApp.Namespace(DestinationFolder).CopyHere oApp.Namespace(FileNameZip).Items
If DeleteSourceFile Then Kill FileNameZip
UnZip_File = Err = 0
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment