I was surprised that no one has asked this question yet, maybe people are not as incapable as me in programming:
I want to program a button in PowerPoint that either changes the color by clicking it or when a certain number is inserted.
I've got this:
Dim clickCount As Integer
Sub ChangeButtonColor()
Dim btn As Shape
Set btn = ActivePresentation.Slides(1).Shapes("Button2") ' Button2 is my button
clickCount = clickCount + 1
Select Case clickCount
Case 1
btn.Fill.ForeColor.RGB = RGB(139, 0, 0) ' dark red
Case 2
btn.Fill.ForeColor.RGB = RGB(255, 0, 0) ' red
Case 3
btn.Fill.ForeColor.RGB = RGB(255, 165, 0) ' orange
Case 4
btn.Fill.ForeColor.RGB = RGB(255, 255, 0) ' yellow
Case 5
btn.Fill.ForeColor.RGB = RGB(0, 255, 0) ' green
Case Else
btn.Fill.Visible = msoFalse ' transparent fill
clickCount = 0 ' set clickCount back to 0
End Select
End Sub
Can someone help me and tell me where the error is? In my opinion the loop should be alright, shouldn't it?
Thanks in advance!
I tried it by doing it with a macro. I don't think that there's another way, if yes let me know.
I already tried it in shapes and interactive buttons but both didnt't work. Perplexity proposed me also a loop with 5 cases and without the else case but nothing of then has worked.
At least when I assign the macro to an interactive button frame gets colored for a sec by clicking it,I don't even know if it's normal.
If I understand it right it should be something with the clickCount right?
