我正在尝试将pdf文件每页拆分为多个新文件。 我在Excel Forum上找到了此代码 我对其进行了修改以适合我的文件夹路径和文件。 我还将Acrobat.tdl库添加到了引用中。(未安装实际的acrobat pro。请遵循此link中建议的步骤)
但是,当我尝试运行代码时,出现错误-运行时错误'429':ActiveX组件无法创建对象。
错误发生在行Set PDDoc = CreateObject("AcroExch.pdDoc")
这是完整的代码:
Sub SplitPDF()
Dim PDDoc As Acrobat.CAcroPDDoc, newPDF As Acrobat.CAcroPDDoc
Dim PDPage As Acrobat.CAcroPDPage
Dim thePDF As String, PNum As Long
Dim f As String, i As Integer, Result As Variant, NewName As String
f = ThisWorkbook.Path & "\"
thePDF = f & "CDE_9740240D_2020-09-08.pdf"
Set PDDoc = CreateObject("AcroExch.pdDoc")
Result = PDDoc.Open(thePDF)
If Not Result Then
MsgBox "Can't open file: " & thePDF
Exit Sub
End If
'...
PNum = PDDoc.GetNumPages
For i = 0 To PNum - 1
Set newPDF = CreateObject("AcroExch.pdDoc")
newPDF.Create
NewName = f & " Page_" & i & "_of_" & PNum & ".pdf"
newPDF.InsertPages -1, PDDoc, i, 1, 0
newPDF.Save 1, NewName
newPDF.Close
Set newPDF = Nothing
Next i
End Sub
有人可以帮助我使此代码正常工作吗。