【发布时间】:2014-11-16 13:50:02
【问题描述】:
我是 Powerpoint VBA 的新手,它与 excel VBA 完全不同。我可以在 excel 中完成,但不能在 powerpoint 中完成,需要一些帮助。我需要在文本框中输入分数。按下按钮后,形状将根据得分值填充颜色。分数越高,填充的形状就越多。以下是我的代码:
Sub AddShape()
Dim counter As Integer
Dim TopValue As Integer
TopValue = 500
For counter = 1 To 5
Set myDocument = ActivePresentation.Slides(2)
With myDocument.Shapes.AddShape(Type:=msoShapeRectangle, Left:=144, _
Top:=TopValue, Width:=72, Height:=5)
.Name = "Rectangle" & counter
.Fill.Visible = msoFalse
.Line.DashStyle = msoLineSolid
End With
TopValue = TopValue - 50
Next counter
Dim tshape As Shape
Set tshape = ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=850, Top:=100,
Width:=90, Height:=40, ClassName:="Forms.TextBox.1", Link:=msoFalse)
End Sub
Private Sub CommandButton1_Click()
If CInt(TextBox1.Text) > 0 And CInt(TextBox1.Text) < 11 Then
ActivePresentation.Slides(2).Shapes("Rectangle1").Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
End Sub
Private Sub TextBox1_Change()
Me.TextBox1.SpecialEffect = fmSpecialEffectFlat
End Sub
Private Sub CommandButton1_Click 中的代码无法正常工作...请指教。我得到提示运行错误“424”需要对象。由于以上所有代码都是从谷歌搜索直接复制的,因此感谢特定代码。我没有太多的vba powerpoint知识。 非常感谢你。
【问题讨论】:
标签: vba powerpoint