使用VBA对某个目录下的PDF进行压缩并设置密码
Sub ProtectWB()
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
Dim zipPwd As String
Dim Pwd As String
FolderName = Sheet1.Range("A1").Value
FolderName1 = Sheet1.Range("A2").Value
zipPwd = Sheet1.Range("A3").Value
Pwd = " -p" & zipPwd & " "
site = ThisWorkbook.Path & "\" & "file" & "\" & FolderName
site_target = ThisWorkbook.Path & "\" & "file" & "\" & FolderName1
Rarexe = "C:\Program Files\7-Zip\7z.exe"
Source = site & "\*.pdf"
Target = site_target & ".rar"
FileString = Rarexe & " a -tzip " & Pwd & Target & " " & Source
Result = Shell(FileString, vbHide)
Application.DisplayAlerts = False
End Sub
- 点赞
- 收藏
- 关注作者
评论(0)