Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to integrate John Walkenbachs colour palette
routine into a marco that I have written. http://www.j-walk.com/ss/excel/tips/tip49.htm I am trying to use it with a form that has multiple buttons on it. I want to be able to call the colour palette from multiple buttons. That is, each button is essentially a colour option button. I then want the button that is clicked to take the colour of the palette colour chosen. The snippet below from the JW code below shows how he takes the colour chosen from the palette and then uses it to colour a shape called "donut". I know I can simply call the main sub from each button click event. However as I have to also ensure that the sub below knows which button to colour, I am assuming that this may entail some other coding for the separate buttons. Does the coding for the buttons need to go into a Class Module? Thanks 'Sub Test_GetAColor1() '' Example of using the GetAColor function '' This sub prompts for a color, then changes '' the color of a shape named Donut Dim UserColor As Long Dim OldSelection As Object Set OldSelection = Selection UserColor = GetAColor() If UserColor < False Then ActiveSheet.Shapes("Donut").Select Selection.ShapeRange.Fill.ForeColor.RGB = UserColor Selection.ShapeRange.Line.ForeColor.RGB = UserColor OldSelection.Select End If End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could use a class module, but unless you have a huge number of buttons,
you can just have the click event call a common procedure (ColorABtn) passing in its identify (which you provide for in the click event). Private Sub CommandButton1_Click() Dim btn as MSForms.CommandButton set btn = me.Controls("CommandButton1") ColorABtn btn End Sub Private Sub CommandButton2_Click() Dim btn as MSForms.CommandButton set btn = me.Controls("CommandButton2") ColorABtn btn End Sub Sub ColorABtn(btn as MSForms.CommandButton) Dim UserColor As Long UserColor = GetAColor() If UserColor < False Then btn.BackColor = ColorValue End If End Sub -- Regards, Tom Ogilvy "ExcelMonkey" wrote in message ... I am trying to integrate John Walkenbachs colour palette routine into a marco that I have written. http://www.j-walk.com/ss/excel/tips/tip49.htm I am trying to use it with a form that has multiple buttons on it. I want to be able to call the colour palette from multiple buttons. That is, each button is essentially a colour option button. I then want the button that is clicked to take the colour of the palette colour chosen. The snippet below from the JW code below shows how he takes the colour chosen from the palette and then uses it to colour a shape called "donut". I know I can simply call the main sub from each button click event. However as I have to also ensure that the sub below knows which button to colour, I am assuming that this may entail some other coding for the separate buttons. Does the coding for the buttons need to go into a Class Module? Thanks 'Sub Test_GetAColor1() '' Example of using the GetAColor function '' This sub prompts for a color, then changes '' the color of a shape named Donut Dim UserColor As Long Dim OldSelection As Object Set OldSelection = Selection UserColor = GetAColor() If UserColor < False Then ActiveSheet.Shapes("Donut").Select Selection.ShapeRange.Fill.ForeColor.RGB = UserColor Selection.ShapeRange.Line.ForeColor.RGB = UserColor OldSelection.Select End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Changing text case in entire database column from JOHN to John | Excel Discussion (Misc queries) | |||
Custom Colour palette | Excel Discussion (Misc queries) | |||
Fill Colour Palette | Excel Discussion (Misc queries) | |||
Colour Palette Problem | Excel Discussion (Misc queries) | |||
Colour Palette Problem | Excel Discussion (Misc queries) |