Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,522
- Office Version
-
- 365
- 2016
- Platform
-
- Windows
I'm working with this code:
The least half of the routine, with all the If-Else If-End If are meant to toggle the shape's colour from the white "off" colour to the "on" red colour" when one of the "xxxALL" shapes is selected.
In a scenario, suppose the user clicks on the shape button for WPEALL. The msgbox dispalys "Caller: WPEALL", however, only 2 of the 6 shapes in the shape range change to red. This is consistant with other selections as well ... in no case do all six shapes in their associated range turn red ... only ever just two, 3 or 4 of them.
I've ensured that all the shape names match what is code.
I have a worksheet activate code that defaults all the shapes to "off" using the same shape ranges, and this doesn't appear to be failing.
Code:
Sub toggle()
Dim myDocument As Worksheet
Dim rtarget As Variant
Set myDocument = Worksheets("Workorders")
Set rtarget = myDocument.Shapes(Application.Caller)
With rtarget
If .Fill.ForeColor.RGB = RGB(255, 255, 255) Then 'OFF to ON
.Fill.ForeColor.RGB = RGB(255, 0, 0)
MsgBox "Caller: " & rtarget.Name
Else
.Fill.ForeColor.RGB = RGB(255, 255, 255) 'ON to OFF
MsgBox "OFF"
End If
End With
If rtarget.Name = "CUEALL" Then
myDocument.Shapes.Range(Array("CUEDR", "CUEDT", "CUEFR", "CUEFT", "CUECR", "CUECT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf rtarget.Name = "CULALL" Then
myDocument.Shapes.Range(Array("CULDR", "CULDT", "CULFR", "CULFT", "CULCR", "CULCT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf rtarget.Name = "HPEALL" Then
myDocument.Shapes.Range(Array("HPEDR", "HPEDT", "HPEFR", "HPEFT", "HPECR", "HPECT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf rtarget.Name = "HPLALL" Then
myDocument.Shapes.Range(Array("HPLDR", "HPLDT", "HPLFR", "HPLFT", "HPLCR", "HPLCT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf rtarget.Name = "RPEALL" Then
myDocument.Shapes.Range(Array("RPEDR", "RPEDT", "RPEFR", "RPEFT", "RPECR", "RPECT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf rtarget.Name = "RPLALL" Then
myDocument.Shapes.Range(Array("RPLDR", "RPLDT", "RPLFR", "RPLFT", "RPLCR", "RPLCT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf rtarget.Name = "WPEALL" Then
myDocument.Shapes.Range(Array("WPEDR", "WPEDT", "WPEFR", "WPEFT", "WPECR", "WPECT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
Else
myDocument.Shapes.Range(Array("WPLDR", "WPLDT", "WPLFR", "WPLFT", "WPLCR", "WPLCT")).Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
End Sub
The least half of the routine, with all the If-Else If-End If are meant to toggle the shape's colour from the white "off" colour to the "on" red colour" when one of the "xxxALL" shapes is selected.
In a scenario, suppose the user clicks on the shape button for WPEALL. The msgbox dispalys "Caller: WPEALL", however, only 2 of the 6 shapes in the shape range change to red. This is consistant with other selections as well ... in no case do all six shapes in their associated range turn red ... only ever just two, 3 or 4 of them.
I've ensured that all the shape names match what is code.
I have a worksheet activate code that defaults all the shapes to "off" using the same shape ranges, and this doesn't appear to be failing.