The access 2007 vba code below works fine, but it leaves acrobat open after it closes. I don't see that I have done anything odd or out of order, but I must be missing something. Any ideas would be greatly appreciated.
Thanks,
Dan
Below is the code that can be pasted into a command button on a form in access.
Const SampleFilePath = "C:\Debug.pdf"
' Create a PDDoc IAC object.
' Since we don't need to launch Acrobat Viewer on the screen, we don't have
' to create Acrobat App object.
Dim pdDoc As Object 'CAcroPDDoc
Set pdDoc = CreateObject("AcroExch.PDDoc")
If pdDoc Is Nothing Then
MsgBox "Failed to create Acrobat PDDoc object."
End
End If
' Open the source PDF document
Dim rc As Long
rc = pdDoc.Open(SampleFilePath)
If rc <> -1 Then
MsgBox "Failed to open PDF document " & SampleFilePath
End
End If
' Acquire the Acrobat JavaScript Object interface from the PDDoc object
Dim jsObj As Object
Set jsObj = pdDoc.GetJSObject
'**************************************************************************************
'I will try to add my logic here
Dim objBkm As Object
Dim a As Variant
Dim s As String
Dim Counter As Integer
Set objBkm = jsObj.bookmarkroot
a = objBkm.Children
For Counter = 0 To UBound(a)
s = s & "Counter: " & Counter & " Name: " & a(Counter).Name & " Open: " & a(Counter).Open & " Style: " & a(Counter).Style & vbCrLf
Next Counter
MsgBox s
'************************************************************************************
'finish
pdDoc.Close
Set a = Nothing
Set objBkm = Nothing
Set fields = Nothing
Set formApp = Nothing
Set avDoc = Nothing
Set jsObj = Nothing
Set pdDoc = Nothing
Does the PDF file close? Or is it Acrobat that's not closing? You cannot force Acrobat to close from the IAC. This has been a problem for a long time. Acrobat runs in the background and there are other factors that can keep it alive.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script