Acrobat Pro Script

I have a simple script to change the zoom view of bookmarks of a PDF in Adobe Acrobat Pro DC.
However, it works when only one document is open, and it doesn’t work on the document that is active if more than one is open. If more than one document is open, then the script only works on the first document rather than the one in focus.

I have tried focus, front, and current document, but all of these fail to be recognized by Adobe Acrobat.

How can I call the active PDF to be the one to act upon?

Thanks.

//

tell application "Adobe Acrobat"
	set docname to name of document 1
	set theseMarks to bookmarks of document docname as list
	
	repeat with n from 1 to count of theseMarks
		set fit type of item n of theseMarks to fit page
		
	end repeat
	
end tell

//

Try using active doc – it a property of the application.

That did the trick!
For that part.

However, I have to run this script while a number of files with the same name are open.
Thus, the script will often not work on the active document, but on the smaller document
that is also open.

How should I filter out the non-active document so the script works just on the active file?

Thank you.

I suspect you’re out of luck. Close all but one of the documents of the same name.