• 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: Getting current slide title in PowerPoint 2004
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting current slide title in PowerPoint 2004


  • Subject: Re: Getting current slide title in PowerPoint 2004
  • From: Nir Soffer <email@hidden>
  • Date: Wed, 31 Jan 2007 02:42:36 +0200


On Jan 30, 2007, at 09:20, kai wrote:

However, it might be worth mentioning that, when analysing a complex slide, the biggest delay in your repeat loop is caused by the number of external calls to PowerPoint. If the slide contains (say) 50 elements, then that's how many calls are made to get each individual shape.

It can be significantly faster to get all the comparison values in one hit, and then iterate through the list in AppleScript. With a busy slide, the following variation executes here some 3-4 times faster than the original. (While the code could be optimised further, the additional gains are not nearly as significant.)

[sniped code]

Testing in Script Editor, your version seems much much faster, however testing in my real setup, a Cocoa application, iterating the shapes is much faster in the common case than getting placeholder types of all the shapes and iterating on the types as you suggest.

I compared these scripts:

-- Script 1 (based on Kay code)
tell application "Microsoft PowerPoint"

tell active presentation to set currentSlide to slide ¬
(current show position of its slide show window's slide show view)

set titleTypes to {placeholder type title placeholder, ¬
placeholder type center title placeholder, ¬
placeholder type vertical title placeholder}

-- 98% of time is spent here
set types to placeholder type of currentSlide's place holders

repeat with i from 1 to count types
set aType to item i of types
-- It is faster the check for missing value then to search in the list of title types
if aType is not missing value and aType is in titleTypes then return content of text range of text frame of shape i of currentSlide
end repeat

return ""

end tell


-- Script 2
tell application "Microsoft PowerPoint"

tell active presentation to set currentSlide to slide ¬
(current show position of its slide show window's slide show view)

set titleTypes to {placeholder type title placeholder, ¬
placeholder type center title placeholder, ¬
placeholder type vertical title placeholder}

repeat with i from 1 to count shapes of currentSlide
set currentShape to shape i of currentSlide
set aType to placeholder type of currentShape
if aType is not missing value and aType is in titleTypes then return content of text range of text frame of currentShape
end repeat

return ""

end tell


These script test where the time is spent in Kay version:

-- Script 3
tell application "Microsoft PowerPoint"

	tell active presentation to set currentSlide to slide ¬
		(current show position of its slide show window's slide show view)

	set types to placeholder type of currentSlide's place holders

end tell

-- Script 4
tell application "Microsoft PowerPoint"

	tell active presentation to set currentSlide to slide ¬
		(current show position of its slide show window's slide show view)

end tell

All scripts saved as compiled scripts.

I run the script from a Foundation tool periodically. I attached the test tool - i guess it can be useful for others. Run it from the command line with the path of the script.

I tested a presentation with 2 slides, both containing 65 shapes. The first one is a test for the best case, when the title is the first shape. The second, the worst case, when the title is the last shape. I restarted PowerPoint before each test because if timings tends to increase over time.

Here are some timings on my G5:

script 1 - best case: 115 milliseconds, worst case: 135 milliseconds
script 2 - best case: 6 milliseconds, worst case 155 milliseconds
scriot 3 - 111 milliseconds
script 4 - 2 milliseconds

Times are averages of about 10 runs.

Tests 3 and 4 show that "set types to placeholder type of currentSlide's place holders" is very expensive.

I assume that in the common case, the title shape is the first one, because when users add shapes, they are added above (after) the placeholders. In this case, the "slower" script is about 19x faster.

Attachment: astime.zip
Description: Zip archive



Attachment: lot of shapes.ppt 2.zip
Description: Zip archive



Best Regards,

Nir Soffer

 _______________________________________________
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/mailman//archives/applescript-users

This email sent to email@hidden

References: 
 >Getting current slide title in PowerPoint 2004 (From: Nir Soffer <email@hidden>)
 >Re: Getting current slide title in PowerPoint 2004 (From: kai <email@hidden>)
 >Re: Getting current slide title in PowerPoint 2004 (From: Nir Soffer <email@hidden>)
 >Re: Getting current slide title in PowerPoint 2004 (From: kai <email@hidden>)

  • Prev by Date: Problem reading UTF8 source email from OS X Mail application
  • Next by Date: Re: Problem reading UTF8 source email from OS X Mail application
  • Previous by thread: Re: Getting current slide title in PowerPoint 2004
  • Next by thread: Re: Getting current slide title in PowerPoint 2004
  • Index(es):
    • Date
    • Thread