Re: Anyone scripting PowerPoint 2004?
Re: Anyone scripting PowerPoint 2004?
- Subject: Re: Anyone scripting PowerPoint 2004?
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 23 Nov 2004 23:00:10 -0800
Title: Re: Anyone scripting PowerPoint 2004?
On 11/23/04 11:20 AM, "Michael Grant" <email@hidden> wrote:
> Is anyone having any luck scripting PowerPoint 2004? I'd like to have a
> script to get a complete text count (the wordcount in
> Properties/Statistics is unreliable and doesn't provide a character
> count), but so far I haven't figured out how to get hold of any text at
> all. Help!
>
It sure is elusive. I finally tracked it down. The one single that has a 'text range' property is 'text frame' (Drawing Suite), and text frame is an element of shape, which i an element of slide.
So
content of text range of text frame of shape 2 of slide 1 of presentation 1
will get you the text of that shape. Unfortunately,
every shape of slide 1 of presentation 1 whose has text frame is true
just gets you 'missing value' instead of the correct list (bug). But a multiple repeat loop through every shape of every slide of the presentation, first checking to see if it has a text frame yields a real result:
tell application "Microsoft PowerPoint"
name of every shape of slide 1 of presentation 1
set totalWordCount to 0
repeat with i from 1 to count (every slide of presentation 1)
set theSlide to slide i of presentation 1
repeat with j from 1 to (count every shape of theSlide)
set theShape to shape j of theSlide
if (has text frame) of theShape then
set totalWordCount to totalWordCount + (count (every word of text range of text frame of theShape))
end if
end repeat
end repeat
end tell
--> 30
Mind you, this includes any words in the Table of Contents in the left panel. It's annoying that although you can isolate each pane of any 'document window', pane has no useful property. But you can check to see which shapes have 'shape type text box', and those are are the main pane (excludes both IOC and Notes):
tell application "Microsoft PowerPoint"
name of every shape of slide 1 of presentation 1
set totalWordCount to 0
repeat with i from 1 to count (every slide of presentation 1)
set theSlide to slide i of presentation 1
repeat with j from 1 to (count every shape of theSlide)
set theShape to shape j of theSlide
if shape type of theShape is shape type text box then
set totalWordCount to totalWordCount + (count (every word of text range of text frame of theShape))
end if
end repeat
end repeat
end tell
--> 29
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden