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


Download 1.37 Mb.
Pdf ko'rish
bet72/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   68   69   70   71   72   73   74   75   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

msoShapeIsoscelesTriangle
msoShape5pointStar
msoShapeLeftArrow
msoShape8pointStar
msoShapeLightningBolt
msoShapeBalloon
msoShapeMoon
msoShapeBentArrow
msoShapeNoSymbol
msoShapeBentUpArrow
msoShapeOctagon
msoShapeCross
msoShapeOval
msoShapeCube
msoShapeParallelogram
msoShapeCurvedDownArrow
msoShapePentagon
msoShapeCurvedLeftArrow
msoShapeRectangle
msoShapeCurvedRightArrow
msoShapeRightArrow
msoShapeCurvedUpArrow
msoShapeRightTriangle
msoShapeDiamond
msoShapeRoundedRectangle
msoShapeDonut
msoShapeSmileyFace
msoShapeDownArrow
msoShapeSun
msoShapeHeart
msoShapeTrapezoid
msoShapeHexagon
msoShapeUpArrow
76 A Scripting Bag of Tricks


Try re plac ing 
msoShapeRectangle
with some of the other shapes from this
list.
Finally, we set some properties of the shape. Since the shape is stored in the
vari able
myShape
, we can use
myShape
to manipulate some of the shape’s
prop er ties:
myShape.Fill.ForeColor.RGB = vbRed
This line takes the shape we just cre ated and stored in the variable
myShape
and
adjusts its color. This looks com plicated, but you just have to remember that if
you want to change the color of a shape, you need to adjust the
.Fill.ForeColor.RGB
. Af ter the equal sign is the color we want. There are
many ways to specify the ex act color, but you can use the fol lowing ba sic col ors:
vbBlack
,
vbRed
,
vbGreen
,
vbYellow
,
vbBlue
,
vbMagenta
,
vbCyan
, and
vbWhite
.
Shapes can also have words in them. If you want to set the text in the shape
to “Hello,” use the fol lowing line:
myShape.TextFrame.TextRange.Text = "Hello"
This is simply a long way of saying that the text in this shape should be set to
“Hello.”
Adding ob jects can be useful, especially if you want the user to make sig-
nificant changes to the pre sentation. In the ex ample in Chapter 10, the user adds
slides to the pre sentation. These slides be come part of the presentation, and there
are an un determined num ber of them (every user that goes through the pre senta-
tion can add slides to it). In most cases, how ever, you will have a few shapes that
you have determined in ad vance. Rather than creating those shapes in VBA, you
would do better to create them in PowerPoint and hide and show them with
VBA. This will prevent your presentation from get ting cluttered with extra
shapes when a user hits a but ton too many times and adds several extra shapes.
Putting the Stu dent’s In put into a Box
When we cre ated a shape ourselves, we could eas ily add text to it. Since the
vari able
myShape
pointed to the shape, we were able to use
myShape
to change
any of the shape’s prop erties, in cluding the text in the shape. We can do the same
thing with a shape that we created with PowerPoint’s drawing tools.
ActivePresentation.SlideShowWindow.View.Slide.Shapes(3)
refers to the third shape on the cur rent slide, so
ActivePresentation.SlideShowWindow.View.Slide.Shapes(3) _
.TextFrame.TextRange.Text
Putting the Student’s In put into a Box 77


refers to the text on the third shape of the current slide.

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   68   69   70   71   72   73   74   75   ...   191




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