1,502
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Dim strRARPath As String
Dim strCompresFile As String '要压缩的文件路径
Dim strTargetFile As String '压缩后的文件路径
Dim retval
Private Sub Command1_Click()
Dim strP As String
Dim lngP As Long
strRARPath = "C:\Program Files\WinRAR\winrar.exe" '执行压缩的可执行文件路径
strCompresFile = "C:\1.xls" '要压缩的文件路径
strTargetFile = "C:\1.rar" '压缩后的文件路径
strP = strRARPath & " A " & strTargetFile & " " & strCompresFile '压缩命令字符串
lngP = Shell(strP, vbHide) '执行压缩命令
End Sub
Private Sub Command2_Click()
Dim strP As String
Dim lngP As Long
strRARPath = "C:\Program Files\WinRAR\winrar.exe"
strTargetFile = "C:\1.rar" '压缩文件路径
strCompresFile = "C:\1\" '解压缩后文件的位置
strP = strRARPath & " X " & strTargetFile & " " & strCompresFile
lngP = Shell(strP, vbHide)
End Sub