使用VBA对某个目录下的PDF进行压缩并设置密码

举报
oysterzz 发表于 2023/03/08 17:17:40 2023/03/08
【摘要】 Sub ProtectPDF()Dim site As StringDim FolderName As StringDim FolderName1 As StringDim Rarexe As StringDim Source As StringDim Target As StringDim FileString As StringDim Result As LongDim zipPwd A...

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

【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。