CommandButton Properties

  • Thread starter Thread starter mcolson
  • Start date Start date
M

mcolson

I am trying to change the properties of a CommandButton I have created
called "Filter". I am having trouble changing the text color. Below
are two things that I have tried. I get the same error either way:
"Object doesn't support this property or method (Error 438)". I'm not
worried about the color at the moment, I can play with that later.
Does anyone know why this may not be working? I am able to change the
font color via the properties box. In fact, I even tried to record
that, but nothing was recorded. According to the properties box the
ForeColor is &H80000012&.

When I step through the code, it breaks when running the ForeColor, so
the rest does work.

With Worksheets("Time Sheet").Shapes("Filter")
.Visible = True
.ForeColor = 1
End With

With Worksheets("Time Sheet").Shapes("Filter")
.Visible = True
.ForeColor.RGB = RGB(1,1,1)
End With

Thanks in advance for any help.

Matt
 
I've also tried changing "Enabled" to "false" and replacing "Shapes"
with "CommandButton" such as

With Worksheets("Time Sheet").Shapes("Filter")
.Visible = True
.Enabled = False
'.ForeColor = 1
End With


With Worksheets("Time Sheet").CommandButton("Filter")
.Visible = True
.Enabled = False
' .ForeColor = 1
End With

I get the same 438 error
 
Is the commandbutton really named filter--or is that the caption on the
commandbutton?

Maybe...

If the caption is "Filter", but the commandbutton is named CommandButton1:

With Worksheets("Time Sheet").CommandButton1
.Visible = True
.ForeColor = 1
'or
'.ForeColor = RGB(1, 1, 1)
End With


If the name is really "Filter":

With Worksheets("Time Sheet").Filter

=====
Another way is to go through the OLEObjects collection:

With Worksheets("Time Sheet").OLEObjects("Filter")
.Visible = True
.Object.ForeColor = 1
End With

(Change Filter to the actual name--not the caption.)
 
Back
Top