Urgent Help needed! run JavaScript zith do script command

Hi y’all

I need to be able to run a fairly complex JavaScript from within an AppleScript. I am quite a novice in Apple Scripting. I found out that I can use the do script command (the script is used with InDesign CS2), but no mather how I put it in the script, I get errors. This is what I tried so far:

– try 1
tell application “Adobe InDesign CS2”
set x to “/Applications/Adobe InDesign CS2/Presets/Scripts/Duplicate Page.js”
do script (POSIX file x) language javascript
end tell

– try 2
tell application “Adobe InDesign CS2”
do script “DuplicatePage.js” language javascript
end tell

I even attached a shortcut (F13) to the JavaScript in InDesign and used the System Events to invoke it, but nothing happens.

I really appreciate any help.

Thanks

Model: G5
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

hi fde,

does escaping your spaces help?


tell application "Adobe InDesign CS2"
    set x to "/Applications/Adobe\ InDesign\ CS2/Presets/Scripts/Duplicate\ Page.js"
    do script (POSIX file x) language javascript
end tell

you could also,


tell application "Adobe InDesign CS2"
    set x to quoted form of "/Applications/Adobe InDesign CS2/Presets/Scripts/Duplicate Page.js"
    do script (POSIX file x) language javascript
end tell

i don’t have InDesign CS2 to test this unfortunately.

Hi Waltr,

Thx for your reply.

This works:

set scripttoRun to “iMac HD:Applications:Adobe InDesign CS2:Presets:Scripts:Duplicate Page.js” as alias
tell application “Adobe InDesign CS2”
do script scripttoRun language javascript
end tell