Display a VBA String Array Element in a PowerPoint Text Shape
Question details
Display a selected VBA string array element in a PowerPoint text shape while a presentation is running.

- Product
- Microsoft PowerPoint
- Device & OS
- not provided
- Scenario
- A presentation uses a VBA string array to store questions, and the user wants to show one question in a slide shape.
- Observed behavior
- The selected array value should appear as the text in the target shape during the slide show.
Check that the target slide and shape exist and that the shape can contain text. Save the presentation as a macro-enabled PowerPoint presentation (.pptm), and allow macros only if you trust the file.
Assign the Array Element to the Shape's Text Range
Use VBA to set the target shape's text to the selected string, then run the macro during the slide show.
In PowerPoint, open the Developer tab and select Visual Basic. In the editor, choose Insert > Module.
Paste this example into the module: Sub ShowQuestion() Dim sQuestions(1 To 2) As String sQuestions(1) = "What is your question?" sQuestions(2) = "What is your next question?" ActivePresentation.Slides(3).Shapes(7).TextFrame.TextRange.Text = sQuestions(1) End Sub Replace the sample strings and slide and shape indexes with your own. If your array is already populated elsewhere, use its selected element in the assignment instead.
On a slide, select a button or shape, choose Insert > Action, and set its click action to Run macro > ShowQuestion.
Start the presentation from Slide Show and click the assigned button. The macro writes the selected array value to shape 7 on slide 3; navigate to slide 3 to see it.

Edit PowerPoint Slides with WPS Presentation
WPS Office is a free, lightweight alternative with a familiar interface for editing presentations and moving between Office files. It does not fix PowerPoint VBA issues, and macro compatibility can vary.

Frequently Asked Questions
How do I display an array element in a PowerPoint shape?
In VBA, assign the element to the shape's text range, for example: ActivePresentation.Slides(3).Shapes(7).TextFrame.TextRange.Text = sQuestions(1). Make sure the indexes identify an existing slide, text-capable shape, and array element.
Is sQuestions(1) always the first array element?
No. It is the first element only if the array's lower bound is 1. Use LBound(sQuestions) to check the lower bound of an initialized array.
Can I refer to the shape by name instead of its index?
Yes. For example, use ActivePresentation.Slides(3).Shapes("QuestionBox").TextFrame.TextRange.Text = sQuestions(1). You can inspect or rename shapes in PowerPoint's Selection Pane.
How can I run the macro during a slide show?
Select a button or shape, open Insert > Action, and assign the macro under Run macro. Start the slide show and click the button. The file must permit the macro to run.
Why is the Run macro action unavailable?
Check that the presentation is saved as a .pptm file and that the macro is a public, parameterless Sub in a standard module. Also check PowerPoint's macro security settings and enable macros only for trusted files.




