Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


ActivePresentation.SlideShowWindow.View.Slide.Shapes(3).TextFrame


Download 1.37 Mb.
Pdf ko'rish
bet75/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   71   72   73   74   75   76   77   78   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

ActivePresentation.SlideShowWindow.View.Slide.Shapes(3).TextFrame _
.TextRange.Text
This re fers to the text in the third shape in the cur rent slide (it’s in teresting how I
can say it in Eng lish in less space than I can say it in VBA). To save typ ing, we
can use a 
With
block. For ex ample, if we want to do several things to the third
shape on the current slide, we can do the fol lowing:
With ActivePresentation.SlideShowWindow.View.Slide.Shapes(3)
.TextFrame.TextRange.Text = "Hello"
.Fill.ForeColor.RGB = vbRed
.Vis 
ible = True
End With
The
With
block (start ing with the first line that be gins with 
With
and end ing
with the line that ends with 
End With
) simply assumes that any thing starting
with a dot re ally in cludes all the stuff on the 
With
line. In Eng lish, it is say ing, “I
want to do the following things to the third shape on the cur rent slide: change the
text to ‘Hello’, change the background color to red, and make the shape visible.”
Ma nip u lat ing Text in Ob jects 79


Add ing Text
Now, suppose you want to add something to the text in your shape, rather
than re place the text. Re member the am persand (
&
). This is used to join two
pieces of text together. We used it when we wanted to dis play text in a 
MsgBox
that included “You are do ing well” and the user’s name. We can use it here to
join what is already in the text box with some ad ditional text. Once we join to -
gether the text we need to stick the joined together text into the
.Text
of the
shape.
Sub AddHello()
With ActivePresentation.SlideShowWindow.View.Slide _

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   71   72   73   74   75   76   77   78   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling