如何用VB改变ppt中的动作按钮颜色

时间:2018-06-16 13:33:11

标签: vba powerpoint

enter image description here我正在使用VB脚本在PPT中创建一个简单的MCQ测验。想要更改包含正确/错误尝试答案的Action Button(而不是msgbox)的颜色。 这是我到目前为止编写的,它工作正常。

Dim numberCorrect As Integer
Dim numberWrong As Integer
Dim Shape As Shape

Sub Correct()
    MsgBox "Well Done! Correct Answer.", vbApplicationModal, " e-Aarohan Quiz "
    numberCorrect = numberCorrect + 1
End Sub

Sub Wrong()
    MsgBox "Sorry! Wrong Answer.", vbApplicationModal, " e-Aarohan Quiz "
    numberWrong = numberWrong + 1
End Sub

1 个答案:

答案 0 :(得分:0)

将此宏添加到项目中并将操作按钮的操作设置指定为运行宏:ActionButton

Sub ActionButton(oSh As Shape)
' This will hand you a reference to the clicked
' action button in oSh
' Use that to determine what to do next

' But to change the foreground color, e.g. to blue
With oSh
    .Fill.ForeColor.RGB = RGB(0, 0, 255)
End With

End Sub