'把演示文稿中所有圖形的顏色改變為紅色
Sub ChangeAllShapeColor()
Dim sld As Slide, shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
shp.Fill.ForeColor.RGB=vbRed
Next
Next
End Sub
'將演示文稿中所有不等于32的字體替換為32
Sub ChangeFontSize()
Dim aSlide As Slide
Dim aShape As Shape
For Each aSlide In ActivePresentation.Slides
For Each aShape In aSlide.Shapes
' 圖形上有文本框嗎?
If aShape.HasTextFrame Then
' 文本框中有文本嗎?
If aShape.TextFrame.HasText Then
' 文本是否小于32,是則改變為32
If aShape.TextFrame.TextRange.Font.Size <>32 Then
aShape.TextFrame.TextRange.Font.Size=32
End If
End If
End If
Next
Next
End Sub
Const pi=3.1415926
Sub 排列圖形()
Dim tShp As Shape
Set tShp=ActivePresentation.Slides(1).Shapes ("TempShp")
Dim x0 As Single
Dim y0 As Single
Dim w0 As Single
Dim h0 As Single
'圖形的中心點
x0=tShp.Left+tShp.Width / 2
y0=tShp.Top+tShp.Height / 2
w0=tShp.Width / 2
h0=tShp.Height / 2
Dim shps As ShapeRange
Dim shp As Shape
Set shps=ActiveWindow.Selection.ShapeRange
Dim angle As Single
'角度
angle=360 / shps.Count
Dim x As Single
Dim y As Single
Dim i As Integer
For Each shp In shps
'圖形的位置
x=x0+w0 * Cos(i * angle * pi / 180)
y=y0+h0 * Sin(i * angle * pi / 180)
shp.Left=x - shp.Width / 2
shp.Top=y - shp.Height / 2
i=i+1
Next
End Sub
' 演示答案選擇的對錯
Public Sub Selectda(ByVal shp As Shape)
Dim txtda As String, shpdui As Shape, shpcuo As Shape
txtda=shp.TextFrame.TextRange.Text ' 獲取所單擊形狀中的文本
Set shpdui=ActivePresentation.Slides(1).Shapes("對") '在答案對錯時顯示對錯圖片
Set shpcuo=ActivePresentation.Slides(1).Shapes("錯")
'對答案進行判斷
Select Case txtda
Case"100" '對時顯示對圖片
shpdui.Left=shp.Left+shp.Width+10
shpdui.Top=shp.Top
shpdui.Visible=True
shpcuo.Visible=False
Case Else '錯時顯示錯圖片
shpcuo.Left=shp.Left+shp.Width+10
shpcuo.Top=shp.Top
shpdui.Visible=False
shpcuo.Visible=True
End Select
End Sub