Re: Getting current slide title in PowerPoint 2004
Re: Getting current slide title in PowerPoint 2004
- Subject: Re: Getting current slide title in PowerPoint 2004
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 29 Jan 2007 21:14:27 -0800
- Thread-topic: Getting current slide title in PowerPoint 2004
Hi, Nir,
It's well-known that you cannot return a result from do Visual Basic to
AppleScript. (The "result", if you can interpret it, would merely indicate
whether the do Visual Basic" command completed successfully without error or
not, not the true result).
As that article of mine you found says, you can return a text (or number, if
coerced to string) result via making a text file in the VBA part fo the
script and reading the file in AppleScript.
But as you already know, that's not going to work in the next version of
PowerPoint (2008, sue out in late 2007). It will continue to work in PPT
2004, of course.
There are a large number of gaps and bugs in PPT 2004's AppleScript. Your
follow-up message shows that you have discovered a good many of them. I have
reported all of these, and many more, and hope that most of them will be
fixed in 2008. Use the 'do Visual Basic' solution for 2004, and check out
what's been fixed when 2008 comes out. You can check for the version (11.x.x
vs. 12.x.x) as string and fiddle with the dots to get it to number form (11
vs 12), and use conditional code.
In particular, 'whose' clauses are not working with shapes of slide. You
ought to be able to
set titleShape to item 1 of (get every shape whose shape type is shape
type place holder and place holder type is in titleTypes)
('first.. whose' never works but 'item 1 of (every...whose)' does work in
most cases, but not for shapes).
It errors because the 'every shape whose...' expression always returns {} -
a bug.
That should be fixed next time.
It would also be nice if shape had a 'title shape' property, of course. But
you'll notice that in the VBA model, Slide does not have a Title Property -
it's the Shapes Collection Object that has the Title Property (rather
weirdly), returning the Title shape. There's no such thing as a Collection
Object in AppleScript, and usually no need for one, but here we lose out.
--
Paul Berkowitz
> From: Nir Soffer <email@hidden>
> Date: Mon, 29 Jan 2007 10:56:03 +0200
> To: AppleScript Users <email@hidden>
> Subject: Getting current slide title in PowerPoint 2004
>
> I'm trying to fetch the title from PowerPoint 2004 slide. It seems
> that there is no direct way to access the title, and you actually
> have to search through the shapes for a one of the title placeholders
> types, and get the text from its text frame. This search become slow
> if the slide contain many shapes.
>
> I use this code:
>
> set slideTitle to ""
>
> set titleTypes to {placeholder type title placeholder, placeholder
> type center title placeholder, placeholder type vertical title
> placeholder}
>
> -- Get the text of the first title placeholder
> repeat with i from 1 to count of shapes of currentSlide
> set aShape to shape i of currentSlide
> set aType to placeholder type of aShape
> if aType is not missing value and titleTypes contains aType then
> set slideTitle to content of text range of text frame of aShape
> exit repeat
> end if
> end repeat
>
>
> In Visual Basic, you can access the title as:
>
> ActivePresentation.Slides(number).Shapes.Title.TextFrame.TextRange
>
> So I tried to run this with do Visual Basic, but the script does not
> return anything. The dictionary says:
>
> do Visual Basic v : Execute a Visual Basic script
> do Visual Basic string : The script to execute
> → anything : the result of the script
>
> But in reality, "anything" turns out to be "nothing". I really like
> this kind of docs!
>
> I made little research, and found this article: http://word.mvps.org/
> mac/Applescript-VBA.html. It seems that the only way to return
> result from do visual basic is by writing it to a file in VBA, and
> reading the file elsewhere.
>
> But I guess that do visual basic is not the way as Microsoft is
> killing VBA in the next Office for Mac anyway.
>
> I wonder if anyone can come up with an easier and faster way to fetch
> the title?
>
>
> 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
>
_______________________________________________
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