vba only works for 1 slide?

  • Thread starter Thread starter Geoff Cox
  • Start date Start date
G

Geoff Cox

Hello,

The code below finds hyperlinks and the intention is that the linked
shape should be selected. The code works for the first slide but then
comes up with an error.

I imagine that the line following is wrong but I'm not clear why..

ActiveWindow.Selection.SlideRange.Shapes(oHl.Parent.Parent.Name).Select

Thanks

Geoff


Sub ShowMeTheHyperlinksSelectThemToo()
' Lists the slide number, shape name and address
' of each hyperlink

Dim oSl As Slide
Dim oHl As Hyperlink

For Each oSl In ActivePresentation.Slides

For Each oHl In oSl.Hyperlinks


If oHl.Type = msoHyperlinkShape Then
ActiveWindow.Selection.SlideRange.Shapes _
(oHl.Parent.Parent.Name).Select

MsgBox "HYPERLINK IN SHAPE" & vbCrLf & _
"Slide: " & vbTab & oSl.SlideIndex & vbCrLf _
& "Shape: " & oHl.Parent.Parent.Name & vbCrLf _
& "Address:" & vbTab & oHl.Address & vbCrLf & _
"SubAddress:" & vbTab & oHl.SubAddress


Else
' it's text
ActiveWindow.Selection.SlideRange. -
Shapes(oHl.Parent.Parent.Parent.Parent.Name).Select
MsgBox "HYPERLINK IN TEXT" _
& vbCrLf & "Slide: " & vbTab & oSl.SlideIndex & _
vbCrLf & "Shape: " & _
oHl.Parent.Parent.Parent.Parent.Name _
& vbCrLf & "Address:" & vbTab & oHl.Address & _
vbCrLf & "SubAddress:" & vbTab & oHl.SubAddress
End If
Next ' hyperlink
Next ' Slide

End Sub
 
Hello,

The code below finds hyperlinks and the intention is that the linked
shape should be selected. The code works for the first slide but then
comes up with an error.

I imagine that the line following is wrong but I'm not clear why..

a) What's the error message?
b) Why select anything?
c) What are you trying to accomplish? Um. Let's put that one first, actually.
 
a) What's the error message?

The code runs OK for the first slide but get error message at thepoint
when it should move to the second slide

"Runtime error '-2147024809 (80070057)';
The item with the specified name wasn't found"

and debug highlights following line,

ActiveWindow.Selection.SlideRange.Shapes(oHl.Parent.Parent.Name).Select
b) Why select anything?

because on a recent occasion, although the code minus my additon for
selecting the link, I could not see where the link was. I had to try
removing text until I found the link.

Plus would just like to understand what causes this error message!
What does the "item with etc" refer to?

Cheers

Geoff
 
On Sun, 23 Apr 2006 20:47:35 EDT, Steve Rindsberg

Steve,

I have just noticed that using the code without my

ActiveWindow.Selection.SlideRange.Shapes(oHl.Parent.Parent.Name).Select

line - the code works and finds the links on both slides but does not
move on to show the second slide. Now I realise it is not meant to do
this but how do you do this? I assume this is behind the runtume error
message?

Geoff
 
Hello,

The code below finds hyperlinks and the intention is that the linked
shape should be selected. The code works for the first slide but then
comes up with an error.

I imagine that the line following is wrong but I'm not clear why..

ActiveWindow.Selection.SlideRange.Shapes(oHl.Parent.Parent.Name).Select

Thanks

Geoff

Two changes:
Sub ShowMeTheHyperlinksSelectThemToo()
' Lists the slide number, shape name and address
' of each hyperlink

Dim oSl As Slide
Dim oHl As Hyperlink

For Each oSl In ActivePresentation.Slides

Add this:

ActiveWindow.View.GoToSlide(oSl.SlideIndex)

For Each oHl In oSl.Hyperlinks


If oHl.Type = msoHyperlinkShape Then
ActiveWindow.Selection.SlideRange.Shapes _
(oHl.Parent.Parent.Name).Select

MsgBox "HYPERLINK IN SHAPE" & vbCrLf & _
"Slide: " & vbTab & oSl.SlideIndex & vbCrLf _
& "Shape: " & oHl.Parent.Parent.Name & vbCrLf _
& "Address:" & vbTab & oHl.Address & vbCrLf & _
"SubAddress:" & vbTab & oHl.SubAddress


Else
' it's text

The character at the end of this line should be an underscore _
not a hyphen -
 
See my reply to your original post ... it's got a few changes to the code and
with them it works here. However, you're not expecting this to run in slide
show mode, correct? If so, adjust expectations. ;-) You can't select
anything in slide show view.
 
See my reply to your original post ... it's got a few changes to the code and
with them it works here. However, you're not expecting this to run in slide
show mode, correct? If so, adjust expectations. ;-) You can't select
anything in slide show view.

Steve,

No - I am mostly interested at the moment in how to use VBA to make
changes/corrections to multiple number of presentations and slides
rather than create interactive presentations for users.

You changes get the code working fine!

Cheers

Geoff
 
Back
Top