Dim site As String
Dim FolderName As String
Dim FolderName1 As String
Dim Rarexe As String
Dim Source As String
Dim Target As String
Dim FileString As String
Dim Result As Long
FolderName = Sheet6.Range("F34").Value
FolderName1 = Sheet6.Range("F35").Value
site = ThisWorkbook.Path & "" & "成果物" & "" & FolderName---相对路径
Rarexe = "D:winRARWinRAR.exe"
Source = site & "*.xls"-----------------------------------------文件夹中的所有.xls文件
Target = site & ".zip"--------------------------------------------压缩后文件保存路径和文件名
FileString = Rarexe & " a " & " -ep " & Target & " " & Source----有“-ep”只压缩指定文件夹,没有“-ep”从跟目录下文件夹到指定的文件夹都压缩
Result = Shell(FileString, vbHide)
Application.DisplayAlerts = False---------------------------------避免系统弹出确认信息
On Error Resume Next-------------------------------------------屏蔽系统报错窗口弹出
Kill site & "*.*"-------------------------------------------------删除指定文件夹下所有文件
Shell "c:windowssystem32cmd.exe /c rd " & site, vbHide-----删除指定文件夹(只有文件夹中所有文件都删除完毕,才能删除文件夹)