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

you need to do this with every object. Anything dimmed not as a
string, long, int etc is an object - destroy them all. Observe the
hierarchy, destroy children before parents.


Steve Hudson - Word Heretic

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


netloss reckoned:

>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.

From: netloss on
Still having the same problem ...

1. I think I've set all objects to Nothing, in the proper order. I also
used Erase on the ararys.

2. for those files that DID get processed, I find that if I open them
and use SaveAs to save them (with the same name) their size is about
half of what it was before. How do I get this effect from code? I am
using this code to save files:

lTemp = pdDoc.Save(PDSaveFull + PDSaveCollectGarbage, sFullFileName)

Thanks, here is the full code with changes.
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 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 + PDSaveCollectGarbage, sFullFileName)
lTemp = pdDoc.Close


Erase aTop
Erase aSubsection
Erase aSection
Erase aPart



Set oBM = Nothing
Set oBMCurrentSection = Nothing
Set oBMCurrentPart = Nothing

Set oBMTop = Nothing
Set oBMR = Nothing
Set oJSO = Nothing
Set pdDoc = Nothing

acroApp.CloseAllDocs
acroApp.Exit

Set acroApp = Nothing

Debug.Print "work complete"

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

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

pdDoc.SaveAs

That PDSaveCollectGarbage is a bloat suspect, maybe just getting rid
of that would help.

Steve Hudson - Word Heretic

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


netloss reckoned:

>Still having the same problem ...
>
>1. I think I've set all objects to Nothing, in the proper order. I also
>used Erase on the ararys.
>
>2. for those files that DID get processed, I find that if I open them
>and use SaveAs to save them (with the same name) their size is about
>half of what it was before. How do I get this effect from code? I am
>using this code to save files:
>
>lTemp = pdDoc.Save(PDSaveFull + PDSaveCollectGarbage, sFullFileName)
>
>Thanks, here is the full code with changes.
>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 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 + PDSaveCollectGarbage, sFullFileName)
>lTemp = pdDoc.Close
>
>
>Erase aTop
>Erase aSubsection
>Erase aSection
>Erase aPart
>
>
>
>Set oBM = Nothing
>Set oBMCurrentSection = Nothing
>Set oBMCurrentPart = Nothing
>
>Set oBMTop = Nothing
>Set oBMR = Nothing
>Set oJSO = Nothing
>Set pdDoc = Nothing
>
>acroApp.CloseAllDocs
>acroApp.Exit
>
>Set acroApp = Nothing
>
>Debug.Print "work complete"
>
>Exit Sub
>Problem:
>MsgBox "Exception thrown by pdfEraseExternalLowLevelBookmarks()."
>End Sub

From: netloss on
OK, I'll try that. Any other ideas on the original problem i.e.Runtime
error '-2147417851(80010105)'
Automation Error
The server threw an exception


Thanks,
NL

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

Obvious suspect is blowing your buffer space, if you do are lots of
editing, you need a regular undoclear to flush the
not-as-quite-infinite-as-we-would-like undo buffer.

If you are doing insane amounts of editing or are trying for automated
pagination type stuff, you also need to regularly update the screen if
you have refresh turned off for speed.

Steve Hudson - Word Heretic

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


netloss reckoned:

>OK, I'll try that. Any other ideas on the original problem i.e.Runtime
>error '-2147417851(80010105)'
>Automation Error
>The server threw an exception
>
>
>Thanks,
>NL