Consulting

Results 1 to 5 of 5

Thread: How to get Shape name based on user selection (As a variant)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Jan 2021
    Posts
    4
    Location

    How to get Shape name based on user selection (As a variant)

    Hello everyone,
    First time being on this forum. I am an avid user of VBA especially with Excel and Visio. I don't know if this has been asked yet but i need help in grabbing the name or id of a user selected shape, in an active powerpoint slide. I want to display a message in case a user clicks a particular shape, with names "Increase" or "Reduce". I set up my code in a SELECT CASE format and i am trying to capture the selected shape as a variant and assign it to my shape object, however i don't get any results. Here is my code. Please and thank you

    Sub determineShapeType()
        Dim osld As Slide
        Dim slideNum As Integer
        Dim Userselection As Variant
        Dim oshp As Shape
        osld = ActivePresentation.SlideShowWindow.View.Slide
        Set Userselection = ActiveWindow.Selection.Shaperange
        Set oshp = osld.Shapes(Userselection.Name)
        Select Case oshp.Name
            Case "Increase"
                MsgBox " You have increased your speed"
                ' Something else
            Case "Reduce"
                MsgBox "You have decreased your speed"
                ' Something else
        End Select
    End Sub
    Last edited by Aussiebear; 01-15-2025 at 12:27 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •