Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default John Walkenbach Colour Palette

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default John Walkenbach Colour Palette

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing text case in entire database column from JOHN to John Kimberly in Palm Springs Excel Discussion (Misc queries) 2 October 10th 06 06:26 PM
Custom Colour palette R.T Excel Discussion (Misc queries) 3 October 12th 05 10:39 PM
Fill Colour Palette skewey Excel Discussion (Misc queries) 2 August 22nd 05 03:12 PM
Colour Palette Problem Simon Excel Discussion (Misc queries) 0 April 14th 05 09:29 PM
Colour Palette Problem Simon Jackson Excel Discussion (Misc queries) 0 April 14th 05 09:26 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"