|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
解压zip,可以用Windows自带的zip模块,打包为rar,只能只是winrar
- Sub Unzip1()
- Dim FSO As Object
- Dim oApp As Object
- Dim Fname As Variant
- Dim FileNameFolder As Variant
- Dim DefPath As String
- Dim strDate As String
- Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _
- MultiSelect:=False)
- If Fname = False Then
- 'Do nothing
- Else
- 'Root folder for the new folder.
- 'You can also use DefPath = "C:\Users\Ron\test"
- DefPath = Application.DefaultFilePath
- If Right(DefPath, 1) <> "" Then
- DefPath = DefPath & ""
- End If
- 'Create the folder name
- strDate = Format(Now, " dd-mm-yy h-mm-ss")
- FileNameFolder = DefPath & "MyUnzipFolder " & strDate & ""
- 'Make the normal folder in DefPath
- MkDir FileNameFolder
- 'Extract the files into the newly created folder
- Set oApp = CreateObject("Shell.Application")
- oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname).items
- 'If you want to extract only one file you can use this:
- 'oApp.Namespace(FileNameFolder).CopyHere _
- 'oApp.Namespace(Fname).items.Item("test.txt")
- MsgBox "You find the files here: " & FileNameFolder
- On Error Resume Next
- Set FSO = CreateObject("scripting.filesystemobject")
- FSO.deletefolder Environ("Temp") & "\Temporary Directory*", True
- End If
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|