Using Applescript to control Excel 2004

K

Kristina

I have an Applescript that I'm using to copy stuff from Excel and
paste it into Word. It worked with both Excel 98 and X, but Excel
2004 doesn't recognize many of the commands.

I'm trying to tell Excel to copy a cell to the clipboard. The
pertinent portion of my existing code looks like this:

tell application "Microsoft Excel"
Activate
«event XCELCpOb» «class crng» "DD1"
end tell

It doesn't recognize the command in the second to last line. The only
"copy" I find in the Excel 2004 dictionary is "copy object", which
doesn't seem to work.

Does anyone know what the new command is? Any help would be greatly
appreciated.

Kristina
 
T

Tom

Try this...

tell application "Microsoft Excel"
activate
set theDataVariable to value of range "theData" as string -- name your
range for ease of use
end tell
set the clipboard to theDataVariable


Hope this helps
Tom
 
P

Paul Berkowitz

I have an Applescript that I'm using to copy stuff from Excel and
paste it into Word. It worked with both Excel 98 and X, but Excel
2004 doesn't recognize many of the commands.

I'm trying to tell Excel to copy a cell to the clipboard. The
pertinent portion of my existing code looks like this:

tell application "Microsoft Excel"
Activate
«event XCELCpOb» «class crng» "DD1"
end tell

It doesn't recognize the command in the second to last line. The only
"copy" I find in the Excel 2004 dictionary is "copy object", which
doesn't seem to work.

Does anyone know what the new command is? Any help would be greatly
appreciated.

You can find the new command in the Excel AppleScript dictionary. All
commands relating to ranges are in the Table Suite. You're looking in the
wrong suite (where you found 'copy object'.) You'll find 'copy range' in the
Table Suite. Although the dictionary doesn't say, it does copy the contents
of the range to the general clipboard.



tell application "Microsoft Excel"
copy range range "$DD1"
end tell
the clipboard
--> whatever you have in DD1

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
K

Kristina

Thanks, Tom and Paul, for your help. I found the dictionary to be
more than a little cryptic when I was only looking in the Excel suite.
The topics in the Table suite are exactly what I'm looking for!

Kristina
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top