我正在阅读论坛帖子: https://forums.adobe.com/thread/604177 并开始尝试它。但我认为该功能根本没有加载。我不确定它背后的原因是什么 - 我认为它必须简单并且可能与库有关。有人可以帮助指出为什么以下代码根本无法编译(由于没有触发任何断点,代码似乎没有在执行时立即运行)。
我加载的库包括
执行此代码的计算机上安装了Acrobat Professional。
Public Function GetPDF() '(FilePath As String) As Object
Dim origPdf As Acrobat.AcroPDDoc
Dim path1 As String
MsgBox ("Start")
path1 = Application.ActiveWorkbook.Path
path1 = path1 & "\31700100.pdf"
Set origPdf = CreateObject("AcroExch.PDDoc")
If origPdf.Open(path1) Then
MsgBox ("weee")
End If
origPdf.Close
Set origPdf = Nothing
End Function
答案 0 :(得分:0)
使用以下方法创建模块:
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Sub GetPDF()
Dim path1 As String
MsgBox "Start"
path1 = Application.ActiveWorkbook.Path
path1 = path1 & "\31700100.pdf"
ShellExecute 0, "Open", path1, "", "", _
vbNormalNoFocus
End Sub
答案 1 :(得分:0)
在VBA中打开文档需要您拥有Acrobat App对象。一旦在函数中有一个app对象,代码就可以工作了。
Public Function GetPDF (FilePath As String) As Object
Dim ArcoApp As New Acrobat.AcroApp
Dim OriPdf As New Acrobat.AcroPDDoc
Set ArcoApp = CreateObject("AcroExch.App")
Set OriPdf = CreateObject("AcroExch.PDDoc")
If OriPdf.Open(FilePath) Then
MsgBox ("weee")
End If
GetPDF = OriPdf
OriPdf.Close
AcroApp.Close
Set OriPdf = Nothing
Set AcroApp = Nothing
End Function