PDA

View Full Version : How to get Shape name based on user selection (As a variant)



tolanio
01-07-2021, 01:54 PM
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

Paul_Hossler
01-08-2021, 06:58 AM
I usually use the Selection Pane to rename them to something meaningful, and Insert, Action to associate clicking a shape with a macro

John Wilson
01-08-2021, 08:13 AM
If you are in show mode then you cannot have a Selection. You can only select in edit mode.

tolanio
01-08-2021, 03:34 PM
Hmm right you are. I can see to it that i use another means

tolanio
01-08-2021, 03:35 PM
Thank you very much. I will definitely try your suggestion and give a reply