Applescript Question: changing format of selection...

A

Andrey_Kazak

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: intel

Greetings!

I entered a long text in an active cell. Then I selected a part of text in the active cell. Now I want to write a script which changes format of selected text or part of the cell.

Here is the needed code for characters XXX-YYY in an active cell:

tell application "Microsoft Excel"
tell font object of (characters XXX thru YYY of active cell)
set subscript to true
end tell
end tell

But how to extract XXX and YYY from the current selection of text in the cell?
 
B

Barry Wainwright

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: intel

Greetings!

I entered a long text in an active cell. Then I selected a part of text in
the active cell. Now I want to write a script which changes format of
selected text or part of the cell.

Here is the needed code for characters XXX-YYY in an active cell:

tell application "Microsoft Excel"
tell font object of (characters XXX thru YYY of active cell)
set subscript to true
end tell
end tell

But how to extract XXX and YYY from the current selection of text in the
cell?


interesting query.

there doesn't appear to be any method of getting the selection within a
cell when the cell is being edited. I can only get a reference to the
whole 'active cell'.
 
B

Bob Greenblatt

interesting query.

there doesn't appear to be any method of getting the selection within a
cell when the cell is being edited. I can only get a reference to the
whole 'active cell'.
You couldn't do this in VBA either. A macro can't run while Excel is in
"Edit" mode. Interesting to attempt in AppleScript, but I doubt that the api
is available, and that's why it doesn't work.
 
A

Andrey_Kazak

Thank you for the replies!

I just tried the folowing:
1) The applescript can be launched and works fine while Excel 2008 is in "cell edit" mode;
2) The issue is that XXX and YYY values can be defined as constants, and I'm looking for a way to extract them from selected portion of cell's content while Excel 2008 is in "cell edit" mode.

Any more thoughts?
 
B

Bob Greenblatt

Thank you for the replies!

I just tried the folowing:
1) The applescript can be launched and works fine while Excel 2008 is in "cell
edit" mode;
2) The issue is that XXX and YYY values can be defined as constants, and I'm
looking for a way to extract them from selected portion of cell's content
while Excel 2008 is in "cell edit" mode.

Any more thoughts?
Have you tried getting the selected text attribute? You might be able to
parse that to search for the beginning and end to set the character counts.
 
A

Andrey_Kazak

Any more thoughts?
Have you tried getting the selected text attribute? You might be able to
parse that to search for the beginning and end to set the character counts.
[/QUOTE]

What do you mean?
It's not clear for me...
 
A

Andrey_Kazak

On 7/15/08 11:24 AM, in article (e-mail address removed)9absDaxw,
:

I'm not an Apple Script expert. But what gets returned when you request text
or selection?

How would you do this in VBA?
 
P

Phillip Jones

How would you do this in VBA?


Forget VBA if you have Excel2008
--
------------------------------------------------------------------------
Phillip M. Jones, CET |LIFE MEMBER: VPEA ETA-I, NESDA, ISCET, Sterling
616 Liberty Street |Who's Who. PHONE:276-632-5045, FAX:276-632-0868
Martinsville Va 24112 |[email protected], ICQ11269732, AIM pjonescet
------------------------------------------------------------------------

If it's "fixed", don't "break it"!

mailto:p[email protected]

<http://www.kimbanet.com/~pjones/default.htm>
<http://www.kimbanet.com/~pjones/90th_Birthday/index.htm>
<http://www.kimbanet.com/~pjones/Fulcher/default.html>
<http://www.kimbanet.com/~pjones/Harris/default.htm>
<http://www.kimbanet.com/~pjones/Jones/default.htm>

<http://www.vpea.org>
 
B

Barry Wainwright

Thank you for the replies!

I just tried the folowing:
1) The applescript can be launched and works fine while Excel 2008 is in
"cell edit" mode;
2) The issue is that XXX and YYY values can be defined as constants, and I'm
looking for a way to extract them from selected portion of cell's content
while Excel 2008 is in "cell edit" mode.

Any more thoughts?

as i replied earlier, even when the cell is in edit mode 'selection'
only returns a reference to the active cell, not to the selected text in
the editing of that cell.

you can't do what you want.
 
A

Andrey_Kazak

Perhaps, there's an opotunity to use Mac OS X native procedures to get selected cell's content properties?
 

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