Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

What's wrong with this AppleScript?

tell application "Pages"



selecttables of body text of front document

set table properties to {width:20.5}


end tell



I want to select all tables in the Pages document and set the column width to 20.5 cm...

But I'm getting an error... Can't set table ...


Any help would be appreciated

AppleScript

Posted on Aug 30, 2013 6:35 AM

Reply
Question marked as Best reply

Posted on Aug 30, 2013 6:43 AM

You may want to consider posting also in the forum for Applescript:


https://discussions.apple.com/community/mac_os/mac_os_x_technologies

9 replies

Aug 30, 2013 8:12 AM in response to thebluedrg

Basically, Pages doesn't know what the width property means and AppleScript doesn't consider width to be a property of the selection, (And you aren't really directing your set command to anything.)


You probably have to do something like this:


tell application "Pages"


tell body text of front document

repeat with i from 1 to (count every table)

tell table i

set width to 20.5

end tell

end repeat

end tell


end tell

Aug 30, 2013 9:14 AM in response to thebluedrg

While those other tasks are fairly simple and straightforward using Pages Find/Replace, they would be very complicated in AppleScript. I think you would have to extract the text from the Pages document and then script a find and replace routine to do what you want, then reinsert the text into the Pages document. That sort of routine is documented in some of the AppleScript books (such as the Sanderson and Rosenthal one).


It might be an interesting educational project, but unless you are dealling with hundreds or thousands of documents, it probably isn't worth reinventing the wheel like this.

What's wrong with this AppleScript?

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