ActivePresentation.SlideShowWindow.View.Slide.Shapes(3). _
TextFrame.TextRange.Font.Name = "Helvetica"
Finally, you can change the color in a number of ways. You have al ready
seen that you can choose from some VBA con stant col ors:
vbBlack
,
vbRed
,
vbGreen
,
vbYellow
,
vbBlue
,
vbMagenta
,
vbCyan
, and
vbWhite
. You can
also set col ors by using an RGB value. RGB stands for Red Green Blue. You
will specify a color by in dicating how much red, how much green, and how
much blue the color contains. For example, to make the text red, you could use
the following:
TextFrame.TextRange.Font.Color.RGB = RGB(255,0,0)
This means that you want lots of red, no green, and no blue (the numbers range
from 0 to 255). You can experiment with the num bers to find just the right shade
you want. For example,
RGB(150,0,75)
gives a lovely shade of purple.
Other Things You Can Do to Text
Many things that traditional PowerPoint can do to text, VBA can do as
well. If you want to make changes while creating a presentation, using
PowerPoint’s menus to do things is prob ably easiest. VBA is useful when you
want to change things in re sponse to something the user does. You can use VBA
to
Cut
,
Copy
,
De
lete
, or
Paste
text:
ActivePresentation.SlideShowWindow.View.Slide.Shapes(3). _
.TextFrame.TextRange.Words(3,2).Cut
ActivePresentation.SlideShowWindow.View.Slide.Shapes(3). _
.TextFrame.TextRange.Words(4,2).Paste
This will cut the third and fourth words in the third shape of the current slide (re-
member the “3,2” means start with the third word and do this for two words).
Next it will find the fourth and fifth words (count ing words with out the text that
was just cut) and replace them with what you cut. So if the text was “one two
84 A Scripting Bag of Tricks
three four five six seven eight nine ten,” the
Do'stlaringiz bilan baham: |