我的代码如下,似乎没有打开pdf请帮忙。我对VBA非常流利,但没有使用adobe的vba面向对象代码。
Option Explicit
Option Compare Text
Sub SeperatePDFFile()
Dim selectpdf As String
Dim caption As String
Dim filter As String
Dim gApp As Acrobat.AcroApp
Dim gPDDoc As Acrobat.AcroPDDoc
Set gApp = CreateObject("AcroExch.App")
Set gPDDoc = CreateObject("AcroExch.PDDoc")
caption = "Please Select an input file must extension .pdf"
selectpdf = Application.GetOpenFilename(filter, , caption)
gPDDoc.Open (selectpdf)
End Sub
答案 0 :(得分:0)
如果您只需要打开PDF,是否有任何理由自动化Acrobat而不仅仅是感谢使用ShellExecute(它几乎打开了在Windows中注册的任何文件)?
Option Explicit
Private 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 Test()
If LaunchFile("C:\temp\somefile.pdf") > 32 Then
' it worked, the file's open
Else
' failed for some reason
End If
End Sub
Function LaunchFile(sFileName As String) As Long
' Requires the full path to the file to be launched
LaunchFile = ShellExecute(0&, vbNullString, sFileName, vbNullString, vbNullString, vbNormalFocus)
End Function