Sub
CreateRectanglesWithTextOnSingleSlide()
Dim
pptApp
As
Application
Dim
pptPres
As
Presentation
Dim
pptSlide
As
Slide
Dim
shp
As
Shape
Dim
i
As
Integer
Dim
rectWidth
As
Single
Dim
rectHeight
As
Single
Dim
list
As
Variant
Dim
xPosition
As
Single
Dim
yPosition
As
Single
Set
pptApp = Application
Set
pptPres = ActivePresentation
Set
pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
list = Array(
"第一行文字"
,
"第二行文字"
,
"第三行文字"
)
rectWidth = 200
rectHeight = 50
xPosition = 50
yPosition = 100
For
i = LBound(list)
To
UBound(list)
Set
shp = pptSlide.Shapes.AddShape(msoShapeRectangle, xPosition, yPosition, rectWidth, rectHeight)
shp.Fill.ForeColor.RGB = RGB(0, 0, 255)
shp.Line.ForeColor.RGB = RGB(255, 255, 255)
With
shp.TextFrame
.TextRange.Text = list(i)
.TextRange.Font.Color.RGB = RGB(255, 255, 255)
End
With
xPosition = xPosition + rectWidth + 20
If
xPosition + rectWidth > pptSlide.Master.Width
Then
xPosition = 50
yPosition = yPosition + rectHeight + 20
End
If
Next
i
End
Sub