Applescript for Set document to Lowercase

Q

quito

Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hi,
What is the script for:
Select all
Set to lowercase
Save
Close saved document
Any help in this matter will be gratefuly acknowledged.
Best,
Daniel
 
P

Peter Jamieson

This was tested on Word 2008.

I don't know how you do it for a complete document, but
a. if you are only concerned with the main body, then the following
should do it:

tell application "Microsoft Word"
set case of content of text object of active document to lower case
save active document
close active document
end tell

b. if you also need to do headers and footers, the following may do it
(but I wouldn't be surprised if you need to trap errors)

tell application "Microsoft Word"
set case of content of text object of active document to lower case
repeat with theSection in (get every section in active document)
set lstHeaderFooters to ¬
{get header theSection index header footer primary} & ¬
{get header theSection index header footer first page} & ¬
{get header theSection index header footer even pages} & ¬
{get footer theSection index header footer primary} & ¬
{get footer theSection index header footer first page} & ¬
{get footer theSection index header footer even pages}
repeat with theHeaderFooter in lstHeaderFooters
set case of content of text object of theHeaderFooter ¬
to lower case
end repeat
end repeat
save active document
close active document
end tell

(NB, because headers/footers actually span sections, that may do work
many more times than is needed, but I don't know how to avoid that).

c. Ideally it would be possible to use story ranges to process every
story range including the footnotes story etc. etc. but
- the following does not work

set case of content of text object of ¬
(get story range of active document story type main text story) ¬
to lower case

- I don't really see why as it should return a text range, and that's
exactly what all the above stuff works with
- no alternative syntax I have tried works either
- impossible for me to tell whether that is inexperience on my part or
a fundamental problem in the way Word's object model is exposed to
Applescript. My guess is that it is the latter, and if so, it really
should be fixed even if MS is bringing back VBA in the next version of
Word, unless of course it does not have the resource to maintain its
Applescript stuff
- perhaps someone else here knows the answer

Peter Jamieson

http://tips.pjmsn.me.uk
 

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