Results 1 to 3 of 3

Thread: Solved: Change Powerpoint Textboxes

  1. #1

    Solved: Change Powerpoint Textboxes


    with the great help of the experts here I have managed to keep my first ever VBA project bouncing along. I have managed to dynamically update multiple powerpoint datasheets in multiple presentations using data from my excel worksheets and am now trying to do the same with textboxes. I am looking for an example of how to alter the text to a new string or value. It can be assumed I already have powerpoint , the presentation, and the slide in question active. I have managed to make a button to change the name of the textboxes from their defaults so I can track them more easily in my code but I can't find the appropriate syntax to address textboxes on a given slide using the name. Also, when updating graphs I was just looping through all shapes on a slide. But if I can name the graph objects can I also refer to these more simply by name rather than checking which type of object they are?

    Regards all,

  2. #2
    VBAX Master
    Jun 2007
    East Sussex
    You can use:
    [VBA]Activepresentation.Slides(1).Shapes("Text Box 4").TextFrame.TextRange.Text = "new text"[/VBA]

    to change the text. You should also be able to refer to charts by the name of the shape.


  3. #3
    Thanks Rory,
    I used this with a slight variation, as I had to refer to the application object variable declared (oPPTApp), and it worked fine.

    oPPTApp.ActivePresentation.Slides(1).Shapes("Title").TextFrame.TextRange.Te xt = sName

    I also found an additional vba macro, and attached to a button, to change the name of the textbox to something more useful than the default. This seems very handy for coding such things.

    Sub ChangeName()
    On Error GoTo ChangeNameError
    ' Is an object selected?
    If ActiveWindow.Selection.Type <> 0 Then
    ' Change the object's name
    ActiveWindow.Selection.ShapeRange.Name = InputBox("Please enter object name", "Rename Object", ActiveWindow.Selection.ShapeRange.Name)
    'Change the slide's name
    ActiveWindow.Selection.SlideRange.Name = InputBox("Please enter slide name", "Rename Object", ActiveWindow.Selection.SlideRange.Name)
    End If
    Exit Sub
    ' This removes the problem if they press cancel.
    End Sub

    Thanks again,

Posting Permissions

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