• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Pages & AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pages & AppleScript


  • Subject: Re: Pages & AppleScript
  • From: Scott Lindsey <email@hidden>
  • Date: Mon, 16 Feb 2009 13:04:07 -0800

Here's a few more details on dealing with graphics in Pages.

When asked for the element "graphic", the document returns all types of graphics:
Floating, inline, and section master page, and in that order: All floating graphics, then all inline, and then all section master graphics.


If you're just wanting to make inline graphics floating, then it's more efficient to work with

	every graphic of body text

For anyone that doesn't quite get why it matters which direction you iterate through the graphics, bear in mind that moving a graphic from inline to floating removes it from the body text.
Consider this script:


tell application "Pages"
	tell (make new document with data "1 2 3 4 5 6 7 8 9 10")
		repeat with i from 1 to 5
			delete word i
		end repeat
		body text
	end tell
end tell

==> "2 4 6 8 10"

Because it's iterating over the objects being deleted, it ends up skipping.
Whereas:


tell application "Pages"
	tell (make new document with data "1 2 3 4 5 6 7 8 9 10")
		repeat with i from 5 to 1 by -1
			delete word i
		end repeat
		body text
	end tell
end tell

==> "6 7 8 9 10"

or, somewhat perversely:

tell application "Pages"
	tell (make new document with data "1 2 3 4 5 6 7 8 9 10")
		repeat with i from 1 to 5
			delete word 1
		end repeat
		body text
	end tell
end tell

==> "6 7 8 9 10"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Scripting ScreenSaverEngine?
  • Next by Date: Re: Generating MP3 Files???
  • Previous by thread: Re: Pages & AppleScript
  • Next by thread: InDesign question
  • Index(es):
    • Date
    • Thread