Shyam -
I have a class that deals with hyperlinks. All my parent.parent calls are
with hyperlink objects to get the type of the hyperlink - shape or range.
Here is the partial code from that class. Note that I store infromation
about each hyperlink in an array and also store the actual hyperlink object
in that array as well. The code works fine on autoshape and texteffect
objects, ignores placeholder objects (as discussed in the other thread as it
doesn't recognize any links) then dies with a PowerPoint error whenever I add
a TextBox object.
If you need more information I'd be happy to e-mail you my example and the
class we are using from the SlideShowBegin event.
The purpose of this code is to look at each hyperlink and then replace each
one with it's absolute link, if broken, searches for the file and replaces
the hyperlink or marks it as broken (with a symbol). I need to be able to
see what the parent.parent object is to look for white space links (which are
ultimately deleted) or in the case of a broken link, color the object
appropriately.
This is working with a slide show from PowerPoint 2003, in compatiblity
mode. I have not noticed a difference in 2007, but have not tested that
fully yet.
Here is the code snip from the class.
============================
Private Type HyperlinkType
strOriginalAddress As String 'Unmolested address of the link
strOriginalSubAddress As String 'Unmolested SubAddress
strAddress As String 'Working copy link address
strSubAddress As String 'working copy sub address
strFIXAddress As String 'calculated address that should be used (NON SAVE)
strSAVEAddress As String 'corrected address, that should be SAVED
lngCSType As SubAddressType 'Type of custom show type
strCSName As String 'Name of the custom show
hyp As Hyperlink 'The hyperlink in question (full object)
blnValid As Boolean 'True if the link in FIXAddress is valid
strPre As String 'Determined pre-base
sldOn As Slide 'The slide object that the hyperlink lives on
lngType As HyperlinkResolve 'Type of hyperlink
blnIgnore As Boolean 'if true, ignore this link
shpBadLink As Shape 'The shape added to show a bad link
shpHyperlink As Shape 'The shape associated with the hyperlink if applicable
txtrHyperlink As TextRange 'the range associated with the hyperlink as
applicable
blnDelete As Boolean 'if true, then delete the link
strToolTip As String ' What to show to the end user
End Type ' Hyperlink Type
Private mahypAllSlides() As HyperlinkType 'array of all hyperlinks on show
Private msld as Slide 'Generic slide object
Private mPres as Presenation 'The presentation - normally activepres
Private Sub SetNCheckHyperLinks()
Dim hypLink As Hyperlink
Dim shp As Shape
Dim intC As Integer
If Not IsNothing(mPres) Then
'check each slide in the presentation.
intC = 0
For Each msld In mPres.Slides
intC = intC + msld.Hyperlinks.Count
Next msld
ReDim mahypAllSlides(intC)
mintHypSlidesCtr = 0
For Each msld In mPres.Slides
For Each hypLink In msld.Hyperlinks
mintHypSlidesCtr = mintHypSlidesCtr + 1
Set mahypAllSlides(mintHypSlidesCtr).hyp = hypLink
Set mahypAllSlides(mintHypSlidesCtr).sldOn = msld
ParseLink
Next hypLink
Next msld
Else
'do nothing, since no presentation set - should not happen
End If 'mPres = nothing
End Sub 'SetNCheckHyperLinks
-------------------------
I iterate through my hyperlink array and parse each hyperlink (there is more
code here, but not included for clarity)
-------------------------
Private Sub ParseLink()
Dim hypLink As Hyperlink
With mahypAllSlides(mintHypSlidesCtr)
If .hyp.Type = msoHyperlinkRange Then
Set .txtrHyperlink = .hyp.Parent.Parent
ElseIf .hyp.Type = msoHyperlinkShape Then
Set .shpHyperlink = .hyp.Parent.Parent
End If
.blnValid = IsValidLink()
End With
End Sub 'ParseLink
Private Function IsValidLink() As Boolean
Dim objParent As Object
Dim blnIgnoreIt As Boolean 'when true, ignore the link completly.
Dim txtr As TextRange
Dim hypLink As Hyperlink
blnIgnoreIt = False
'parent.parent = Hyperlink->ActionSetting->Shape/TextRange
Set objParent = mahypAllSlides(mintHypSlidesCtr).hyp.Parent.Parent
If TypeName(objParent) = "TextRange" Then
If Trim(objParent) = "" Or Trim(objParent) = vbCrLf Then
blnIgnoreIt = True
End If 'if parent is a return or space
End If 'ignore spaces
<lots more processing>
End Function 'IsValidLink
================================
1. The code dies on "Set objParent =
mahypAllSlides(mintHypSlidesCtr).hyp.Parent.Parent"
2. I can not even look at the mahypAllSlides object in the watch window
because when I expand it, a fatal error is thrown.
3. I will continue to test this and see if I can narrow it down, but I
remember in previous tests that it was the parent.parent object. Perhaps it
has something to do with setting the hyperlink object in an array or possibly
linked to the hyperlink problem you referred to in my other thread. I will
simple this down to determine problems. This is what I have now though.
thanks!!!!
Andy