RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
Good day,
I have some controls on a userform that have their BackColor property set to 'vbRed'. I want these controls to blink on and off. Eventually there should be an acknowledge button to stop it but for now I'm working on getting these controls to blink. Here's my attempt. I'm getting an error:
"Cannot the run the maco {macro location string of 'StartFlashing'}. The macro may not be available in this workbook or all macros may be disabled"
The idea is to identify all controls that have a backcolor vbRed (not all do) and store their names in an array. I checked the array, they're all in there. I can set the controls 'visible' property to False but looks like I can't re-run the Flashing subroutine. Any thoughts?
Setup Code
Flashing Code
I have some controls on a userform that have their BackColor property set to 'vbRed'. I want these controls to blink on and off. Eventually there should be an acknowledge button to stop it but for now I'm working on getting these controls to blink. Here's my attempt. I'm getting an error:
"Cannot the run the maco {macro location string of 'StartFlashing'}. The macro may not be available in this workbook or all macros may be disabled"
The idea is to identify all controls that have a backcolor vbRed (not all do) and store their names in an array. I checked the array, they're all in there. I can set the controls 'visible' property to False but looks like I can't re-run the Flashing subroutine. Any thoughts?
Setup Code
VBA Code:
'member Array for Userform
Private msFlashArray() As Variant
Private Sub CheckControls()
For Each ctrl In Me.Controls
If ctrl.BackColor = vbRed Then
i = i + 1
ReDim Preserve msFlashArray(1 To i)
msFlashArray(i) = ctrl.Name
End If
Next ctrl
' I confirmed that the correct controls were indeed listed in the FlashArray
Call StartFlashing
Application.OnTime (Now + TimeValue("00:00:01")), "StartFlashing"
End Sub
Flashing Code
VBA Code:
Private Sub StartFlashing()
Dim item As Variant
For Each item In msFlashArray
If Me.Controls(item).Visible = True Then
Me.Controls(item).Visible = False
ElseIf Me.Controls(item).Visible = False Then
Me.Controls(item).Visible = True
End If
Next item
End Sub
Last edited: