AppleScripting

R

renaissanceboy

I'm a beginner AppleScript programmer, and I'm looking for a way to
write a script that will do something really simple, but for some
reason, i can't get it to work. I need a command that opens the Labels
tool in Word. I can't get the command that appears in the Word 2004
AppleScript Dictionary to work, but this might be because I'm not that
good at reading the dictionaries, I'm really confused by them. If
anyone either knows of another way of doing this rather than using that
command, or can help me understand how I should use that command, I'd
really appreciate it.
 
P

Paul Berkowitz

I'm a beginner AppleScript programmer, and I'm looking for a way to
write a script that will do something really simple, but for some
reason, i can't get it to work. I need a command that opens the Labels
tool in Word. I can't get the command that appears in the Word 2004
AppleScript Dictionary to work, but this might be because I'm not that
good at reading the dictionaries, I'm really confused by them. If
anyone either knows of another way of doing this rather than using that
command, or can help me understand how I should use that command, I'd
really appreciate it.

You just want to open the labels dialog, or you want to actually _do_
something? Applescript is at its best if you just tell it to do things
behind the scenes without opening dialogs - it can probably do anything you
want. But it should be able to open the dialog too, if that's really all you
want.

Could you please be more specific?

A for help with the really complex and often confusing AppleScript Word
dictionary, you should get the Word 2004 AppleScript References at MacTopia
(www.microsoft.com/mac/) / Resources/Developer/AppleScript. But we can offer
help here too.

--
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.
 
M

matt neuburg

Paul Berkowitz said:
You just want to open the labels dialog, or you want to actually _do_
something? Applescript is at its best if you just tell it to do things
behind the scenes without opening dialogs - it can probably do anything you
want. But it should be able to open the dialog too, if that's really all you
want.

try
with timeout of 1 second
tell application "Microsoft Word"
activate
display Word dialog (get dialog dialog tools create labels)
end tell
end timeout
end try

Pretty hacky but it was the best I could come up with. The problem is
that "display Word dialog" waits for the user to interact with the
dialog. So to stop the script from waiting I introduced a deliberate
short timeout, along with a try block to catch the resulting "error".

As Paul says, it's hard to understand why anyone would actually want to
do this. m.
 
R

Ritika Pathak [MSFT]

There is another way to open the Labels dialog without the need to hack
using time out mechanisms.
Simply use the following script:

tell application "Microsoft Word"
activate
show(get dialog dialog tools create labels)
end tell

If you would like to open the dialog for a specified amount of time, please
use the "time out" option to specify the duration. For example, script for
opening Labels dialog for 6 seconds would be:
show(get dialog dialog tools create labels) time out 6000

Thanks,
Ritika Pathak [MSFT]
Mac Word Test
Macintosh Business Unit
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

matt neuburg

Ritika Pathak said:
There is another way to open the Labels dialog without the need to hack
using time out mechanisms.
Simply use the following script:

tell application "Microsoft Word"
activate
show(get dialog dialog tools create labels)
end tell

No, you're wrong about that. Naturally I tested this approach before my
previous posting. But I found that "show" has the same behavior as
"display Word dialog": it waits for the user to close the dialog. The
workaround is the very same hack I used in the other script.
If you would like to open the dialog for a specified amount of time, please
use the "time out" option to specify the duration. For example, script for
opening Labels dialog for 6 seconds would be:
show(get dialog dialog tools create labels) time out 6000

But that also closes the dialog. You have to keep in mind what the OP
seemed to be asking for: the script should open the dialog and *stop*:
the dialog is open and the script is not running. The hack I show below
achieves that. Your script does not. m.
 
R

renaissanceboy

i'd like to open the dialog, then paste the contents of a variable into
it. do you know how to do that?
 

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