Re: OK, I give up (Or: How to fill in a cell in Excel 2004)
Re: OK, I give up (Or: How to fill in a cell in Excel 2004)
- Subject: Re: OK, I give up (Or: How to fill in a cell in Excel 2004)
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 27 May 2004 16:42:26 -0700
On 5/27/04 2:23 PM, "Rebecca O'Connell" <email@hidden> wrote:
>
>
I just downloaded the trial copy of Office 2004 and it's "improved and
>
expanded" implementation of applescript has broken all of my existing Excel
>
applescripts, which I9m given to understand it was supposed to do. Well, it
>
did it. Now I can9t figure out how to fix it. I know there9s supposed to be
>
a manual coming out, but if some more dictionary-savy person here could tell
>
me how to do just one or two simple things while I9m waiting for it, I would
>
really appreciate it.
The most important thing would be to do this:
1. Quit all Office 2004 apps.
2. Quit the script editor you use.
3. Open (reinstall if necessary) Excel X.
4. Open your script editor.
One by one:
5. Open a saved Excel script.
6. Save As Text in a different location. (That makes a new file. Or else
first make a duplicate of the script, open the duplicate, and Save As Text.)
When finished all of them:
7. Quit Excel X.
8. Quit the script editor you use.
9. Open Excel 2004.
10. Open your script editor.
One by one:
11. Open the text files.
Now you will at least see your old terms like Activate and Value and Cell,
instead of obscure <<raw codes>> > Many terms will simply recompile as is
(as 'activate', 'value' and 'cell' in these cases). Many other terms and
commands will have to be redone using the new terminology and syntax, but at
least you'll know what you're trying to do since you'll be able to read the
old terms as English and not as obsolete raw codes.
>
>
The things I would really like to know how to do are get and set the value
>
of a cell. If I tell it to "return first cell of selection" when I have cell
>
R1C1 selected, I get...
>
+class X117; "$A$1" of selection of application "Microsoft Excel" (+class
>
X117; appears to be the range class).
You have to quit Script Editor, which is still remembering the Excel X
dictionary, and re-open it so that it can learn the Excel 2004 dictionary.
Then you won't get these raw codes but instead:
range "$A$1" of selection of application "Microsoft Excel"
'cell' is a subclass of range, which is used when resolving results, and you
now have to use the "A1" form of address, not "R1C1" which was buggy for
non-English languages. the best is to use the 'absolute' reference "$A$1".
>
...so I can get a range, but I cannot for the life of me figure out how to
>
get or set the value of a cell in the range.
set value of cell "$C$7" to "test" -- or 23, or whatever
once you have the right Excel 2004 dictionary working in script editor.
tell application "Microsoft Excel"
set sr to selection
set value of cell "A1" of sr to 35
end tell
sets the topmost left corner cell of the selected range (using 'relative
reference "A1" instead of the absolute reference which happened to be "$D$4"
in my case), even where the selection is somewhere in the middle of the
sheet. Nice and easy.
>
>
Formula is listed as a property of the range class, but when I ask it to
>
"return formula of selection" I get "missing value".
>
>
I9ve tried...
>
set first Cell of Selection to "asdf"
>
set Selection to "asdf" (with a single cell selected)
>
set Value of Selection to "asdf"
>
set Value of first Cell of Selection to "asdf"
That one will work once you've got the Excel 2004 dictionary active in
your script editor:
tell application "Microsoft Excel"
set value of first cell of selection to "asdf"
end tell
--> (works)
>
set Formula of first Cell of Selection to "asdf"
That also works:
set formula of first cell of selection to "cuthbert"
--> (works)
>
set Formula of Selection to "asdf"
>
set FormulaR1C1 of Selection to "asdf"
>
set text of Selection to "asdf"
>
--with no luck.
>
>
It also won't let me activate the application any more ("can't continue
>
Activate..."). I still have Excel 2001 on my computer and it is called by
>
the same name ("tell app 'Microsoft Excel'") so maybe that is the problem
>
with that.
Wrong 'Activate'. Once you have the correct dictionary it uses the standard
'activate' all the other Mac apps use (built-in to AppleScript) rather than
its old proprietary one.
Just quit and relaunch (with Excel 2004 open) your script editor to access
the Excel 2004 dictionary.
>
>
The good news is that all of my Entourage scripts that I9ve tried so far and
>
my MS Word Find and Paste function, are still working. The ones that use
>
Word will work in which ever version of Word I happen to have running (or
>
2004 if I have them both running). Sweet.
Anything you have using 'do Visual Basic' in Word X will continue to work in
2004. But you can now write new scripts using straight Applescript rather
than 'do Visual basic'. the greatest advantage (aside from not having to
learn VB syntax, but the AS syntax for Word can get quite contorted) is that
it will return actual results to your script.
Entourage has always had good AppleScript support. There have been additions
and improvements in 2004 but everything that worked in X will continue to
work in 2004.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.