Bug in VBA code to count colors/shapes
Thanks again for your help Tom. I have another question. I have several
buttons I choose to use to change a rectangle to various colors. All of my
buttons begin with "cbo" (something I picked up along the way). I have been
trying to figure out how to use InStr (x,y) to skip shapes beginning with
"cbo" but I can't get the syntax right. Any ideas? I was figuring on "If
Instr(whatever) 0 Then ... end if"
Again, thank you kindly for your assistance.
Scott
"Tom Ogilvy" wrote in message
...
I see nothing in your code that would relate to the takefocusonclick
property.
What I found was that the commandbutton caused a permission denied error
because it doesn't support the properties you are trying to check. If I
avoided the commandbutton, it worked.
Private Sub cboCountColors_Click()
On Error GoTo Err_cboCountColors
Dim shp As Shape
Dim nRed As Long
Dim nBlue As Long
For Each shp In ActiveSheet.Shapes
If shp.Name < "cboCountColors" Then
Select Case shp.Fill.ForeColor.SchemeColor
Case 10: nRed = nRed + 1
Case 12: nBlue = nBlue + 1
End Select
End If
Next shp
Exit_cboCountColors:
Debug.Print nRed, nBlue
Exit Sub
Err_cboCountColors:
MsgBox Err.Description
Resume Exit_cboCountColors
End Sub
This was true with both TakeFocusOnClick set to either True or False.
--
Regards,
Tom Ogilvy
|