Applescript to change Pages underline to italic

I need to scan 85,000 words in a Pages document and change all underlined words to italic. I have the following code:


tell application "Pages" to tell front document

repeat with i from 1 to (count every word)

tellwordi

if underline type is in {single underline, double underline} then set properties to {underline type:none, italic:true}

endtell

end repeat

endtell


This works great as far as it goes. The only problem is that this changes only the words in the document, but not the spaces between them. So it will turn this: (The quick brown fox) into this: (The_quick_brown_fox). But what I want is this: (The quick brown fox).


So how would this Applescript need to look to change the formatting of the space after the word, as well as the formatting of the word itself? Or maybe the code should add a delete and space after each changed word? I'm not sure.


Any help is HUGELY appreciated!

iMac (27-inch, Late 2012), OS X Mountain Lion (10.8.3)

Posted on May 17, 2013 7:17 PM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript to change Pages underline to italic

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.