Error: -1719 System Events. Can get menu bar of process “QuarkXpress”.

This script works OK if I run it from script editor or script debugger but if run it within Quark pull down scripts menu I get this Error: -1719 System Events got an error: Can get menu bar of process “QuarkXpress”. Invalid index. What am I doing wrong? I need help please. Our IT guy is suggesting me to use Automator since it can record steps but I rather use Applescript. I not pursuing printing a postscript anymore because the pdf boxes like trim & bleed are missing when the final is pdf is created. (My friend posted this in the Quark forums too but this site is more reliable)

tell application "QuarkXPress"
    activate
    try
        tell document 1
            set DocName to name as text
        end tell
        
        
        tell application "System Events"
            tell process "QuarkXPress"
                tell menu bar 1
                    tell menu bar item "File"
                        tell menu "File"
                            tell menu item "Export"
                                tell menu "Export"
                                    click menu item "Layout as PDF..."
                                end tell
                            end tell
                        end tell
                    end tell
                end tell
                tell window "Export as PDF"
                    delay 20 --allows me time to select the correct PDF style settings                    
                    --click button "Save" of window "Export as PDF" -- currentlly not working I get this Error:-1728. System Events got an error: Cant get window "Export as PDF" of process "QuarkXpress". I'm clicking save button
                    end tell
            end tell
        end tell
        close document 1 saving no -- I need the document close as soon it finish saving the pdf from the window Export as PDF
    on error the error_message number the error_number
        set the error_text to "Error: " & the error_number & ". " & the error_message
        display dialog the error_text buttons {"OK"} default button 1
        return the error_text
    end try
end tell

This is just a guess, but look at this line:

click menu item “Layout as PDF…”

Sometimes those 3 dots can mess you up. In most menu items it called an elipsis and is typed as one character, not 3 periods. You type it by holding the option key while pressing the semicolon. Try that and see if it helps.

Hi There,

The printing to ps is the method I use and then distill it. I think I’m correct in saying to can add bleed etc to the ps file.


set MyDocWidth to width of bounds of current page as real
set MyDocHeight to height of bounds of current page as real

tell print setup
				set paper width to MyDocWidth + 50
				set paper height to MyDocHeight + 50
end tell

Regards,

Nick