|
楼主 |
发表于 2022-11-16 10:45
|
显示全部楼层
本帖最后由 bluesky_0 于 2022-11-16 15:35 编辑
详细解释见帖子: https://club.excelhome.net/thread-1646256-1-1.html
内容如下,可能有无效的代码,我是业务的,凑合用吧.
Private Sub CommandButton4_Click()
'每四页PDF保存第一页,删除2-4页
Dim pdApp As Acrobat.AcroApp
Dim pdDoc As Acrobat.AcroPDDoc
Dim pdPage As Acrobat.AcroPDPage
Dim jso As Object
Dim watermark As String, watermarkID As Integer, watermarkfile As String
Dim II As Integer, pagenum As Integer, delnum As Integer, ROW_DEL As Integer
Set pdApp = CreateObject("AcroExch.App")
Set pdDoc = CreateObject("AcroExch.PDDoc")
cropfile = ThisWorkbook.Path & "\" & Sheet1.Range("A" & 2) '需要DEL文件名
pdDoc.Open (cropfile) '打开PDF文件
Set jso = pdDoc.GetJSObject
pagenum = pdDoc.GetNumPages() '得到页数
For II = 1 To pagenum \ 4
delnum = II '
OK = jso.DeletePages(delnum, delnum + 2)
Next
pdDoc.Save 1, cropfile & ".PDF" '保存文件,覆盖不提示
pdDoc.Close '关闭文件
Set pdDoc = Nothing
Set pdApp = Nothing
MsgBox "OK"
End Sub
|
|