-
Solved: Change Powerpoint Textboxes
Hi,
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,
Jason
-
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.
Regards,
Rory
-
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)
Else
'Change the slide's name
ActiveWindow.Selection.SlideRange.Name = InputBox("Please enter slide name", "Rename Object", ActiveWindow.Selection.SlideRange.Name)
End If
Exit Sub
ChangeNameError:
' 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
-
Forum Rules