Hi, thanks for reading! Here’s the problem, quite simple actually:
All I want is to ‘set the text of A_Cell to Some_Data’, something like:
tell application "Microsoft Excel"
tell the front Worksheet
set (text of Cell (("A" & The_position) as text)) to The_name
set (text of Cell (("B" & The_position) as text)) to The_phone
set (text of Cell (("C" & The_position) as text)) to The_type
set (text of Cell (("D" & The_position) as text)) to Voice_available
end tell
end tell
Maybe I’m missing a ‘tell the front workbook’ or something, but I think I tried all that!! This wont work either:
set Cell (("A" & The_position) as text)) to The_name
( with all of the above included and also changed)
nor will work:
write Cell ... (this one actually points to files, obviously with no success)
So I’m kinda angry, rather than confused, it seems like a very simple command…
Well, help apreciated!! One more thing, after all the changes I would like the file to be saved will all the new information in the same file with all the same properties, ‘as it was’ (appart from the changes made in text, I mean). Would that be as simple as:
tell...
save the front worksheet in The_file
end tell
Or am I missing something? The thing is I couldn’t even try this part since the other one wont work! Thanks for any help!
Excel is recordable so open a new window in Script Editor, click the “Record” button, and then do some things in Excel and the AppleScript code will be added to your new script. Anyway, the answer to your problem is:
Also take a look at the Excel AppleScript dictionary–amazingly scriptable, actually.
Works like a charm!! Still, Excel has some serious issues in making a difference between R1C1 (Cell “A1” ) and C1 (considered as Column 1, not Cell “C1”), but, whatever, I now how it works now, so it’s just a matter of making it work! Thanks a lot!
According to the dictionary (and my experience) the text of a cell is read only. The Formula or (the FormulaR1C1 which I generally use) are writable.
I was surprised by the comment about Excel being recordable though. That was my first complaint when I upgraded to Office X. I’ve generally lived without it and just used the dictionary. Or if I’m really stuck I fire up Excel 98 in Classic and record that.
I called MIcrosoft support about the recordable issue and they gave me some unstaisfying song and dance. I don’t think the guy I talked to (way back when) even knew what applescript was. Kept trying to lead me into VB instead.
So now I’m curious what the variables are. Why does my Excel not record when it apparently does for others?
What version of Excel are you using? According to the about box from within Excel, I’m using Excel X for Mac Service Release 1 – 10.1.5 (030814) from get info in the Finder on Mac OS X 10.3.2 / AS 1.9.3 / Script Editor 2.0 (v43) and it is indeed recordable. Did you install the extra macro stuff (VBA) – I forget exactly what it’s called – when you installed Office? That may make a difference.