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


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

Sub AddRectangle()
Dim myShape As Shape
Set myShape = _
ActivePresentation.SlideShowWindow.View.Slide.Shapes. _
AddShape(Type:=msoShapeRectangle, Left:=100, Top:=100, _
Width:=200, Height:=200)
myShape.Fill.ForeColor.RGB = vbRed
myShape.TextFrame.TextRange.Text = "Hello"
End Sub
Adding PowerPoint Ob jects 75


This looks complicated, but it is not as complicated as it looks. This procedure
does three things: It cre ates the rectangle, it turns it red, and it puts the word
“Hello” in side. Let’s take it line by line:
Dim myShape As Shape
We are going to cre ate a shape, so we create a variable to hold that shape. That
way, once the shape is cre ated, we can re fer to it later in the procedure. Next we
create the shape:
Set myShape = _
ActivePresentation.SlideShowWindow.View.Slide.Shapes. _
AddShape(Type:=msoShapeRectangle, Left:=100, Top:=100, _
Width:=200, Height:=200)
ActivePresentation.SlideShowWindow.View.Slide
gives us the
cur rent slide.
Shapes
gives us the shapes on the slide, and the
AddShape
method is used to add a shape to the shapes on the slide. Now, ev erything be -
tween the pa rentheses is simply telling you about the shape:
• The
Type
is what shape you are cre ating:
msoShapeRectangle
for 
a rect an gle.

Left
and 
Top
are the lo cation on the screen of the top left corner of
the shape

Width
and 
Height
are how wide and tall the shape is.
Some other shapes you might use in stead of 
msoShapeRectangle
are:
msoShape4pointStar

Download 1.37 Mb.

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




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