I have searched and found similar topics but none have solved my problem. Hopefully it is basic.
I am trying to open a document in Acrobat 9 Pro.
The basic script looks like this:
set theFile1 to "MacHD:Users:atoqe:Desktop:Step Test File_pifn.pdf"
tell application "Adobe Acrobat Pro"
launch
activate
set doc1 to open theFile1
end tell
The replies tab give this:
I can’t figure out what “missing value” refers to. I know it can be used as a variable Null value, but I just set the value. And “error number 0” is No Error in the applescript codes.
I am trying to eventually do a replace pages with this Applescript, but I think this error is messing it up. Ideas?
Model: MBP
AppleScript: 2.2.1
Browser: Firefox 23.0
Operating System: Mac OS X (10.7)
May you try to open Acrobat by hand then run the script :
set theFile1 to "MacHD:Users:atoqe:Desktop:Step Test File_pifn.pdf" as alias
tell application "Adobe Acrobat Pro"
activate
set doc1 to open theFile1
end tell
Maybe Acrobat was not completely loaded when your original script tried to open the file.
KOENIG Yvan (VALLAURIS, France) samedi 21 septembre 2013 09:23:24
No, the document opens just fine in Acrobat. I simplified my script to ask the question here. The problem comes in the rest of the script when I try to do a Replace pages by referencing the variable “doc1”. I want to open two docs, replace page one of doc1 with page 1 of doc 2. Here is the rest of the script:
set theFile1 to "MacHD:Users:atoqe:Desktop:Step Test File_pifn.pdf"
set theFile2 to "MacHD:Users:atoqe:Desktop:approbationg.pdf"
tell application "Adobe Acrobat Pro"
launch
activate
set doc1 to open theFile1
set doc2 to open theFile2
replace pages doc1 over 1 from doc2 starting with 1 number of pages 1
end tell
This script ends with an error:
You see that the replace pages command is trying to use “missing value” when it resolves the variable “doc1” or “doc2”. I’m sure this is a syntax problem, but I don’t know the finer points of Applescript to know how to reference an open document correctly in the replace Pages command.
Then the problem is that ‘open’ isn’t returning a reference to the document when it opens it and there’s no point in setting a variable to the result.
I don’t have Acrobat Pro, so I can’t check it out myself. But it looks as if you’d have to open each document in turn and set a variable to the ‘front document’ after each one. Hopefully this will produce name references to the documents. Or else open the documents and refer to them as documents 1 and 2, although that’s not without risk if their stacking order changes.
FYI, Acrobat is one of those apps where the index refers to the order of opening, not its stack order. It also has an “active doc” property, so the best bet might be to open, then store the return value of “active doc” as a reference.