Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Changing the text in a shape during a slide show

Problem

You have shapes with numbers in them and want to let the user click the shape to increase/decrease the number, as might be useful when you're creating a game in PowerPoint.

Solution

Set each shape's Action Setting to Run Macro: MacroName

PowerPoint will then run the VBA subroutine called MacroName when you click on the shape during a slide show.

Note: Substitute any acceptable subroutine name for MacroName.

Mac PowerPoint has a few bugs that keep this trick from working as smoothly as it does in Windows PowerPoint but the code below works around these issues and works in either version of PowerPoint.

Sub IncrementNumber(oSh as Shape)

   Dim oSl as Slide
   Dim oShTemp as Shape

   ' oSh.Parent returns a valid reference to the shape's host slide:  
   Set oSl = ActivePresentation.Slides(oSh.Parent.SlideIndex)

   ' oSh.Name works as well

   ' So we use those two bits to get a reference 
   ' to the clicked shape like so
   Set oShTemp = oSl.Shapes(oSh.Name)
   With oShTemp
       .TextFrame.TextRange.Text = _
       Cstr(CLng(oShTemp.TextRange.Text) + 1)
   End With

End Sub

About this bit:

Cstr(CLng(oShTemp.TextRange.Text) + 1)

oShTemp.TextRange.Text gets the current text in the shape, Clng converts it from text to a number so we can do arithmetic on it, adds 1 to it, then Cstr converts it back to text so we can plug it back into the shape's text.

See How do I use VBA code in PowerPoint? to learn how to use this example code.


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Changing the text in a shape during a slide show
http://www.pptfaq.com/FAQ01265-Changing-the-text-in-a-shape-during-a-slide-show.htm
Last update 31 May, 2018
Created: 31 May, 2018