View Full Version : How to modify the text inside a text box with VBA?
Lucas Olivei
02-26-2008, 07:29 AM
Hello guys.
I have a problem when I try to locate a named text box in a named slide to change the text inside the text box.
Any of you know how to do it?
For example this code here is not working:
ActivePresentation.Slides("Anlass").Select
ActiveWindow.Selection.ShapeRange("Group 88").Select
ActiveWindow.Selection.ShapeRange.GroupItems(Index:=3).TextFrame.TextRange. Select
ActiveWindow.Selection.ShapeRange.GroupItems(Index:=3).TextFrame.TextRange. Characters(Start:=15, Length:=10).Select
ActiveWindow.Selection.TextRange.Font.Bold = msoTrue
ActiveWindow.Selection.Unselect
Thanks in advance
John Wilson
02-26-2008, 08:39 AM
You should probably explain exactly what you are trying to do!
Is the text really in groupitems(3)?
Assuming it is try:
Sub boldme()
ActivePresentation.Slides("Anlass").Shapes("Group 88").GroupItems(3) _
.TextFrame.TextRange.Characters(15, 10).Font.Bold = msoTrue
End Sub
monokoi
02-27-2008, 12:27 PM
Well I've come close to what I wanted to do:
I can increment the score of the quiz, and it is displayed in the TextBox of the current Slide.
How can I assign this value to a textbox on the next slide?
I've tried copying / pasting the box, but a new objectname will be assinged :(
How can I keep my score and have it show on each slide?
My code so far:
Sub addToPersonA()
Dim resultA As Integer
On Error Resume Next
resultA = ActivePresentation.Slides(1).Shapes("Text Box 5").TextFrame.TextRange.Text
Set tb = ActivePresentation.Slides(1).Shapes("Text Box 5")
resultA = resultA + 1
With tb
.TextFrame.TextRange.Text = resultA
.Font.Size = 32
End With
End Sub
Anyone still awake to save me before sunset?
monokoi
02-27-2008, 04:11 PM
Updated my post above - hope it's better now ?!
John Wilson
02-28-2008, 12:44 AM
Few things then:
Because you have Dim ResultA inside the sub it will be reset to zero each time it runs
Place it OUTSIDE of the sub but in the same module then it will keep score
Dim ResultA
Sub AddtoPersonA
etc
If you name the textbox yourself rather than the default name it won't change when pasted
In 2007 you can do this in the selection pane in earlier versions you must use vba :
Sub Namer()
'select the first box and run this
On Error Resume Next
ActiveWindow.Selection.ShapeRange(1).Name = "MyBox"
End Sub
To add text on the current slide in the show
With ActivePresentation.SlideShowWindow.View.Slide _
.Shapes("MyBox").TextFrame.TextRange
.Text = ResultA
.Font.Size = 32
End With
Hope that helps
John
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.