Sorry, but that is not the script that I used. So here it is:
$inputfolder = IniRead (@ScriptDir & "\client.ini", "Folder", "in", "Not Found")
$outputfolder = IniRead (@ScriptDir & "\client.ini", "Folder", "out", "Not Found")
$delay = IniRead (@ScriptDir & "\client.ini", "Delay in milliseconds", "delay", "Not Found")
while 1 = 1
$inpdf = FileFindFirstFile ($inputfolder & "\*.pdf")
If $inpdf = -1 Or @error = 1 Then
Sleep (2000)
ContinueLoop
Else
$procpdf = FileFindNextFile ($inpdf)
Do
$movepdf = FileMove ($inputfolder & "\" & $procpdf, @ScriptDir & "\temp\" & $procpdf, 1)
Sleep (1000)
Until $movepdf = 1
$Aapp = ObjCreate ("AcroExch.App")
$Aapp.Hide
$AVDoc = ObjCreate ("AcroExch.AVDoc")
$AVDoc.Open (@ScriptDir & "\temp\" & $procpdf,"")
$PDDoc = $AVDoc.GetPDDoc
$PDDoc.SetPageMode (3) ;Set view to pages and bookmarks panel
Sleep ($delay)
$AForm = ObjCreate ("AFormAut.App")
;expand all bookamrks
$EX = "" _
& " function openBM(bm, nLevel)" & @LF _
& " {for (var i = 0; i < nLevel; i++) bm.open = true;" & @LF _
& " if (bm.children != null)" & @LF _
& " {for (var i = 0; i < bm.children.length; i++) openBM(bm.children[i], nLevel + 1); }" & @LF _
& " }" & @LF _
& " openBM(this.bookmarkRoot, 1)"
$AForm.Fields.ExecuteThisJavascript($EX)
$JSO = $PDDoc.GetJSObject
Sleep ($delay)
$JSO.saveAs ($outputfolder & "\" & $procpdf)
Sleep ($delay)
$PDDoc.Close()
$Aapp.CloseAllDocs()
Sleep ($delay)
EndIf
WEnd
When I change the $Aapp.Hide to $Aapp.Show, I don't encounter any error. Can you please check if this will also work in your version of Acrobat? Thanks!