I want all command buttons to change color from a VBA code

I have 50 generators, which is a lot of buttons. Its easy to strong arm this, and write a line specifying each one, but I'm sure there is an elegant solution where I could say:

For Each Commandbutton in ThisDisplay.objects

.BackColor = color1

.ForeColor = color2

next CommandButton

but for now I'm stuck with this ugliness:

  ButtonSR1.BackColor = color1

  ButtonSR1.ForeColor = color2

 

  ButtonSR2.BackColor = color1

  ButtonSR2.ForeColor = color2

 

  ButtonWR1.BackColor = color1

  ButtonWR1.ForeColor = color2

 

  ButtonWR2.BackColor = color1

  ButtonWR2.ForeColor = color2

 

  ButtonWR3.BackColor = color1

  ButtonWR3.ForeColor = color2

 

this goes on for a while, I'll spare you the rest...

Parents Reply Children
No Data