Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Goto Shape name in powerpoint via vba

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
518
US
Hello,

I have a shape on a slide that I would like to jump to via VBA. The reason for this is the slide number may change and I want to use the shape as the anchor.

Using Alt + F10 I can set the shape name such as "Triangle". What I'd like to do is search the active presentation for "Triangle", return the slide number, and using to switch slides using GoToSlide or something similar.

Code:
ActivePresentation.SlideShowWindow.View.GotoSlide

Also, if there is a way to call the internal hyperlink to a specific slide that might also work. If you use the link feature in Insert > Link > Place in This Document > "Selected Slide"

Even if the slide order changes, the link will automatically update and stay on the correct slide.

I know it can call an external link.

Code:
ActivePresentation.FollowHyperlink _
    Address:="[URL unfurl="true"]https://example.microsoft.com",[/URL] _
    NewWindow:=True, AddHistory:=True

Any other possible methods would be appreciated too.

Thanks,

Mike
 
Since this is a VBA question, you have a better luck in forum707


---- Andy

There is a great need for a sarcasm font.
 
As Andy says, the VBA frum may be more appapriate - but since it is Christmas … a function like the one below should work:

Code:
[blue]Public Function SlideFromShapeName(strShapeName As String) As Slide
    Dim mySlide As Slide
    Dim Found As Slide
    
    For Each mySlide In ActivePresentation.Slides
        On Error Resume Next [COLOR=green]' ignore failures to find[/color]
        Set Found = mySlide.Shapes(strShapeName).Parent
        On Error GoTo 0
        If Not Found Is Nothing Then
            Set SlideFromShapeName = Found
            Exit For
        End If
    Next
End Function[/blue]
 
There is.SlideID that remains unchanged even if slides move, get added or deleted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top