can somebody please point out the error in my thinking (or the error in PP2007)?
I am trying to add multiple hyperlinks to text in a shape on a slide in PowerPoint. The idea is to create a single slide with quick links to all the other slides, based on their titles).
I have some code which scans all the slide titles and successfully adds many shapes, each with text and ONE hyperlink per title to my slide, eg
Set tb = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal,50,50,500,200)
Dim tb as Shape
With tb.TextFrame.TextRange
.text = SlideTitleText
end with
with tb.ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
.Hyperlink.Address = SlideNumber
.Hyperlink.SubAddress = SlideTitleText
End With
But this leaves me with a whole lot of shapes and positioning them to avoid overlaps is painful. So I'd prefer a single shape with all the text in it.
Using the Powerpoint application itself, it is easy to add different hyperlinks to individual words in a shape's text.
However, the following does NOT work in VBA:
when I iterate over my collection of slide titles and place the strings all into a single shape's text, and then assign hyperlinks using
'(where a is the begining position and b the end position of the text being added...)
with.tb.TextFrame.TextRange.Characters(a,b).ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
.Hyperlink.Address = SlideNumber
.Hyperlink.SubAddress = SlideTitleText
end with
The result is that only the last slide title in the shape's text has a hyperlink associated with it.
So I guess there is a flaw in my logic somewhere... Somehow, when I do this in VBA, the program is wiping out all the previous hyperlinks and only leaving the most recently added link (correctly linked to only the last string added to the shape, not to the rest of the texts).
Any ideas?
Thanks,
Oliver
Submitted via EggHeadCafe - Software Developer Portal of Choice
GOT INTERFACE?
http://www.eggheadcafe.com/tutorials/aspnet/35c59ac7-0594-4f40-8767-d64c223339e7/got-interface.aspx
For an internal link
.Address=""
.SubAddress="SlideID,SlideIndex,Title"
though you will find that "SlideIndex,," works
I would use the .Words rather than .Characters probably
eg
With tb.TextFrame.TextRange.Words(a).ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
.Hyperlink.Address = ""
.Hyperlink.SubAddress = "256,2,My Slide"
End With
--
john ATSIGN PPTAlchemy.co.uk
Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
"Oliver Snow" wrote:
> .
>
> I think the problem is with your address and sub address.
>
> For an internal link
> .Address=""
>
> .SubAddress="SlideID,SlideIndex,Title"
>
>
> though you will find that "SlideIndex,," works
>
> I would use the .Words rather than .Characters probably
>
> eg
> With tb.TextFrame.TextRange.Words(a).ActionSettings(ppMouseClick)
> .Action = ppActionHyperlink
>
> .Hyperlink.Address = ""
>
> .Hyperlink.SubAddress = "256,2,My Slide"
>
> End With
In addition to what John said, are you adding the hyperlinks as you go or
after you add the titles. You might have better luck adding them after you
add all your titles (or vice versa if that was what you were doing).
--David
--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
From Oliver's description of what he wants to end up with, it'd take a working VBA
macro a second, maybe two to do the job for a medium to large show.
How fast can you do it manually? ;-)
==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/
PPTools add-ins for PowerPoint
http://www.pptools.com/
<g> First you open the bottle, sniff the cork. Pour a little, swirl it around
in the glass, enjoy the bouquet ...
...
An hour or so? ;-)