Excel2004, System Events & NSReceiverEvaluationScriptError
Excel2004, System Events & NSReceiverEvaluationScriptError
- Subject: Excel2004, System Events & NSReceiverEvaluationScriptError
- From: Larry McMunn <email@hidden>
- Date: Thu, 16 Dec 2004 11:16:52 -0500
I'm moving a lot of scripts from Excel X to Excel 2004. I'm slowly getting comfortable with the changes, but there's a lot to relearn--especially without the ability to record to get a starting point. This makes debugging even more important. When I working on a script, I have problems checking it in debugging mode. I'm using Excel 2004 with the Service Pack applied and Script Debugger 3.0.8. A part of this particular project is making a PDF of a worksheet using the "Save As PDF" button in the "Print" window.
The following script works exactly as expected when saved as an application and run with the source workbook open.
When run from compiled mode, whether debugging is enabled or not, I get the following message --"System Events got an error: NSReceiverEvaluationScriptError: 4" upon clicking the "Save As PDF" button:
-----------------------------------------------------
tell application "Excel_2004"
activate
activate object worksheet "MyDesiredSheet"
tell worksheet "MyDesiredSheet"
set left header of page setup object to "xx"
set center header of page setup object to "Here's My PDF"
set right header of page setup object to "xx"
end tell
tell application "System Events"
tell process "Excel_2004"
keystroke "p" using command down
-- problem occurs at the next line
click button "Save As PDF" of UI element 4 of window "Print"
keystroke "d" using command down
keystroke "My Desired Worksheet"
keystroke return
end tell
end tell
end tell
-----------------------------------------------------
This happens as the script appears above and also if the 'tell application "System Events"' block is put outside the tell Excel block. This is just a small portion of the complete script. I would like to be able to run the script from Script Debugger as I work on it rather than closing and running as an application to test each change.
Any help out there?
--
Sincerely,
Larry McMunn
President
McMunn Associates, Inc.
900 Haddon Avenue, Suite 302
Collingswood, NJ 08108
(856) 858-3440
---------------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden