These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

acrobat will not close after manipulating bookmark

Dan Washington
Registered: Aug 7 2008
Posts: 14

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

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There's nothing wrong with your code, but you may want to release all the object acquired from the document before closing it.

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

Dan Washington
Registered: Aug 7 2008
Posts: 14
Thom,

Thanks for looking at this. The pdf file seems to close fine ( as I can open it, make changes and save it) however, in task manager I can see that Acrobat.exe is still open...and the memory usage keeps growing each time I run the application..eventually causing stability issues, so I can't release this to the users.

I just can't figure out what isn't getting closed, or if I'm closing something out of order?

I can see Acorbat.exe closing fine if I just don't call the command "a = objBkm.Children" and do other things besides working with the bookmarks.

Do you have any guidance on closing "all the objects acquired from the document"? I thought that PdDoc.close would cover this, and I tried JSObj.close, and objBkm.close ( in reverse order of opening them) too but still memory is not freeing up.


Thanks,
Dan