From: netloss on
Hi -

I am processsing a file folder with about 60 pdf files in it, from word
2002 vba (windows XP - using acrobat 6). My code opens each file and
deletes some bookmarks before moving on to the next. Around pdf file 35
or so, I get the following error:

Runtime error '-2147417851(80010105)'
Automation Error
The server threw an exception

I have to go in and kill the Acrobat process to get it running again.
The program will then get a liltle further through the file list before
throwing the same exception.

The code uses GetJSObject to get at the bookmarks, if that makes any
difference ...

I tried closing (or set to Nothing) all the objects and the acrobat app
itself at the end of the process for each file, but this doesn't help.

Unlike most of the posts I've read through, this error happens every
time. I've tried it on two different computers. The other one has word
2000, but otherwise is the same.

Thanks in advance for any advice,
NL

From: Word Heretic on
G'day "netloss" <netloss(a)metacrawler.com>,

I suspect a variable isn't being destroyed properly, but if you are
freezing screen updates, you may want to refresh the screen every 20
pdf's

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


netloss reckoned:

>Hi -
>
>I am processsing a file folder with about 60 pdf files in it, from word
>2002 vba (windows XP - using acrobat 6). My code opens each file and
>deletes some bookmarks before moving on to the next. Around pdf file 35
>or so, I get the following error:
>
>Runtime error '-2147417851(80010105)'
>Automation Error
>The server threw an exception
>
>I have to go in and kill the Acrobat process to get it running again.
>The program will then get a liltle further through the file list before
>throwing the same exception.
>
>The code uses GetJSObject to get at the bookmarks, if that makes any
>difference ...
>
>I tried closing (or set to Nothing) all the objects and the acrobat app
>itself at the end of the process for each file, but this doesn't help.
>
>Unlike most of the posts I've read through, this error happens every
>time. I've tried it on two different computers. The other one has word
>2000, but otherwise is the same.
>
>Thanks in advance for any advice,
>NL

From: netloss on
Here is the code that creates all the pdf objects and at the end (tries
to) destroy them. What is the proper way to destroy them?


Thanks,
NL




Sub pdfEraseExternalLowLevelBookmarks(sDocSectionNum As String,
sFullFileName As String)
'### 1-31-06
'On Error GoTo Problem

'### open the acrobat application
Dim acroApp As Acrobat.CAcroApp
Set acroApp = CreateObject("AcroExch.App", "")


'### open the pdf file
Dim pdDoc As Acrobat.CAcroPDDoc
Set pdDoc = CreateObject("AcroExch.PDDoc", "")

pdDoc.Open (sFullFileName)

'### get the book mark root
Dim oJSO As Object
Dim oBMR As Object
Set oJSO = pdDoc.GetJSObject
Set oBMR = oJSO.BookMarkRoot

Dim aTop() As Variant
aTop = oBMR.Children

Dim i As Integer
Dim s As String
Dim k As Integer
Dim m As Integer

Dim oBMTop As Object
Set oBMTop = aTop(0)

Dim aPart() As Variant
aPart = oBMTop.Children

Dim aSection() As Variant
Dim oBMCurrentPart As Object
Dim oBMCurrentSection As Object
Dim aSubsection() As Variant
Dim oBMCurrentSubsection As Object
Dim oBM As Object

'### step through each Part
For i = LBound(aPart) To UBound(aPart)
Set oBMCurrentPart = aPart(i)
If pdfBookmarkHasChildren(oBMCurrentPart) = True Then
aSection = oBMCurrentPart.Children
Else
GoTo SkipI
End If
'### step through each section
For k = LBound(aSection) To UBound(aSection)
Set oBMCurrentSection = aSection(k)
If Left(oBMCurrentSection.Name, 11) = sDocSectionNum Then GoTo
SkipK

'### step through each subsection (level 1) and delete them and
their children
If pdfBookmarkHasChildren(oBMCurrentSection) Then
aSubsection = oBMCurrentSection.Children
For m = LBound(aSubsection) To UBound(aSubsection)
Set oBM = aSubsection(m)

oBM.Remove
Next m
End If

SkipK:
Next k
SkipI:
Next i

Dim lTemp As Long
lTemp = pdDoc.Save(PDSaveFull, sFullFileName)
lTemp = pdDoc.Close
Set oJSO = Nothing
Set oBMR = Nothing
Set oBMCurrentPart = Nothing
Set oBMCurrentSection = Nothing
Set oBM = Nothing
Set oBMTop = Nothing

acroApp.CloseAllDocs
acroApp.Exit


Exit Sub
Problem:
MsgBox "Exception thrown by pdfEraseExternalLowLevelBookmarks()."
End Sub

From: Word Heretic on
G'day "netloss" <netloss(a)metacrawler.com>,

At the end,

Set AcroApp = Nothing


Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


netloss reckoned:

>Here is the code that creates all the pdf objects and at the end (tries
>to) destroy them. What is the proper way to destroy them?
>
>
>Thanks,
>NL
>
>
>
>
>Sub pdfEraseExternalLowLevelBookmarks(sDocSectionNum As String,
>sFullFileName As String)
>'### 1-31-06
>'On Error GoTo Problem
>
>'### open the acrobat application
>Dim acroApp As Acrobat.CAcroApp
>Set acroApp = CreateObject("AcroExch.App", "")
>
>
>'### open the pdf file
>Dim pdDoc As Acrobat.CAcroPDDoc
>Set pdDoc = CreateObject("AcroExch.PDDoc", "")
>
>pdDoc.Open (sFullFileName)
>
>'### get the book mark root
>Dim oJSO As Object
>Dim oBMR As Object
> Set oJSO = pdDoc.GetJSObject
>Set oBMR = oJSO.BookMarkRoot
>
>Dim aTop() As Variant
>aTop = oBMR.Children
>
>Dim i As Integer
>Dim s As String
>Dim k As Integer
>Dim m As Integer
>
>Dim oBMTop As Object
>Set oBMTop = aTop(0)
>
>Dim aPart() As Variant
>aPart = oBMTop.Children
>
>Dim aSection() As Variant
>Dim oBMCurrentPart As Object
>Dim oBMCurrentSection As Object
>Dim aSubsection() As Variant
>Dim oBMCurrentSubsection As Object
>Dim oBM As Object
>
>'### step through each Part
>For i = LBound(aPart) To UBound(aPart)
> Set oBMCurrentPart = aPart(i)
> If pdfBookmarkHasChildren(oBMCurrentPart) = True Then
> aSection = oBMCurrentPart.Children
> Else
> GoTo SkipI
> End If
> '### step through each section
> For k = LBound(aSection) To UBound(aSection)
> Set oBMCurrentSection = aSection(k)
> If Left(oBMCurrentSection.Name, 11) = sDocSectionNum Then GoTo
>SkipK
>
> '### step through each subsection (level 1) and delete them and
>their children
> If pdfBookmarkHasChildren(oBMCurrentSection) Then
> aSubsection = oBMCurrentSection.Children
> For m = LBound(aSubsection) To UBound(aSubsection)
> Set oBM = aSubsection(m)
>
> oBM.Remove
> Next m
> End If
>
>SkipK:
> Next k
>SkipI:
> Next i
>
>Dim lTemp As Long
>lTemp = pdDoc.Save(PDSaveFull, sFullFileName)
>lTemp = pdDoc.Close
>Set oJSO = Nothing
>Set oBMR = Nothing
>Set oBMCurrentPart = Nothing
>Set oBMCurrentSection = Nothing
>Set oBM = Nothing
>Set oBMTop = Nothing
>
>acroApp.CloseAllDocs
>acroApp.Exit
>
>
>Exit Sub
>Problem:
>MsgBox "Exception thrown by pdfEraseExternalLowLevelBookmarks()."
>End Sub

From: netloss on
I put the line

set acroApp = Nothing

immeditately after

acroApp.exit

and I still get the same error in the same location in my list of pdfs.