Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default blinking button

Hi,

I have a button on a userform.
i would like te button to blink (making the button ackcolor switch from red
to white to red to white etc...) for 3 seconds.
How can i do this in VBA ?
Thanks,
Pierre

--
Message posted via http://www.officekb.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default blinking button

use the wait ant the backcolor propierties

"Pierre" wrote:

Hi,

I have a button on a userform.
i would like te button to blink (making the button ackcolor switch from red
to white to red to white etc...) for 3 seconds.
How can i do this in VBA ?
Thanks,
Pierre

--
Message posted via http://www.officekb.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default blinking button

hi filo666
Thanks for the help but do you have some vba code for me please ?
Thanks,
Pierre

filo666 wrote:
use the wait ant the backcolor propierties

Hi,

[quoted text clipped - 4 lines]
Thanks,
Pierre


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200511/1
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default blinking button

In your activate event:

Private Sub UserForm_Activate()
CommandButton1.BackColor = 4966415
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waittime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waittime
CommandButton1.BackColor = 4966555
Application.ScreenUpdating = True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waittime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waittime
CommandButton1.BackColor = 3966555
Application.ScreenUpdating = True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waittime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waittime
CommandButton1.BackColor = 2966555
Application.ScreenUpdating = True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waittime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waittime
CommandButton1.BackColor = 4566555
Application.ScreenUpdating = True
End Sub

I know it looks difficult, you just need to find the colors you want and
change the number of the color, any further question please aske me, I made
this fast, but with some time you can make this in 4 or 5 lines (with for
statements)
HTH

"Pierre via OfficeKB.com" wrote:

hi filo666
Thanks for the help but do you have some vba code for me please ?
Thanks,
Pierre

filo666 wrote:
use the wait ant the backcolor propierties

Hi,

[quoted text clipped - 4 lines]
Thanks,
Pierre


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200511/1

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default blinking button


Hello Pierre,

Here is a macro than can be used with any button name on any form
Insert a new VBA module into your project and paste the code into.

EXAMPLES OF CALLING BLINKBUTTON MACRO

If you want to blink CommandButton1...
Call BlinkButton(CommandButton1)

If you have 2 UserForms open and want to blink CommandButton1 o
UserForm2...
Call BlinkButton(UserForm2.CommandButton1)

You can make the call from anywhere in your code.


Code
-------------------
'/////////////////////////////////////////'
'/ /'
'/ Sleep suspends program activity /'
'/ for an interval given in Milli- /'
'/ Seconds. 1 millisecond = 1/1000 /'
'/ of a second. /'
'/ /'
'/////////////////////////////////////////'


Public Declare Function Sleep _
Lib "kernel32.dll" _
(ByVal dwMillisecs As Long) As Long

Public Sub BlinkButton(Button As MSForms.Control)

'To use BlinkButton:
'Call BlinkButton(CommandButton1)

Dim N As Long
Dim OrigClr
Dim X As Object
Dim FormName

OrigClr = Button.BackColor
Set X = Button

'Get the Name of the UserForm the button is on
Do
FormName = X.Parent.Name
On Error Resume Next
Set X = X.Parent
If Err.Number < 0 Then
Err.Clear
Exit Do
End If
Loop


'The UserForms collection can only be indexed by a number
For I = 0 To UserForms.Count - 1
If UserForms(I).Name = FormName Then
N = I
Exit For
End If
Next I

'Blink the button - 1/2 second White, 1/2 second Red, 3 times
For I = 1 To 3
Button.BackColor = vbWhite
UserForms(N).Repaint
Sleep (500)
Button.BackColor = vbRed
UserForms(N).Repaint
Sleep (500)
Next I

'Set the button back to it's orignal color
Button.BackColor = OrigClr

End Sub

-------------------

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48738



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default blinking button

Hi Leath,

Thanks for your help. This works fine !!!

I adjusted your code a little bit because the line:

UserForms(N).Repaint

caused my whole application to sort of blink...
I changed it to

DoEvents

And now only the button is flashing !!!
thanks again,
Pierre




Leith Ross wrote:
Hello Pierre,

Here is a macro than can be used with any button name on any form
Insert a new VBA module into your project and paste the code into.

EXAMPLES OF CALLING BLINKBUTTON MACRO

If you want to blink CommandButton1...
Call BlinkButton(CommandButton1)

If you have 2 UserForms open and want to blink CommandButton1 o
UserForm2...
Call BlinkButton(UserForm2.CommandButton1)

You can make the call from anywhere in your code.

Code
-------------------
'/////////////////////////////////////////'
'/ /'
'/ Sleep suspends program activity /'
'/ for an interval given in Milli- /'
'/ Seconds. 1 millisecond = 1/1000 /'
'/ of a second. /'
'/ /'
'/////////////////////////////////////////'


Public Declare Function Sleep _
Lib "kernel32.dll" _
(ByVal dwMillisecs As Long) As Long

Public Sub BlinkButton(Button As MSForms.Control)

'To use BlinkButton:
'Call BlinkButton(CommandButton1)

Dim N As Long
Dim OrigClr
Dim X As Object
Dim FormName

OrigClr = Button.BackColor
Set X = Button

'Get the Name of the UserForm the button is on
Do
FormName = X.Parent.Name
On Error Resume Next
Set X = X.Parent
If Err.Number < 0 Then
Err.Clear
Exit Do
End If
Loop


'The UserForms collection can only be indexed by a number
For I = 0 To UserForms.Count - 1
If UserForms(I).Name = FormName Then
N = I
Exit For
End If
Next I

'Blink the button - 1/2 second White, 1/2 second Red, 3 times
For I = 1 To 3
Button.BackColor = vbWhite
UserForms(N).Repaint
Sleep (500)
Button.BackColor = vbRed
UserForms(N).Repaint
Sleep (500)
Next I

'Set the button back to it's orignal color
Button.BackColor = OrigClr

End Sub

-------------------

Sincerely,
Leith Ros


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200511/1
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
Blinking Button apis Excel Discussion (Misc queries) 2 November 20th 11 01:47 AM
Blinking cell PBANKS Excel Discussion (Misc queries) 4 June 30th 06 04:32 PM
blinking text lucas Excel Programming 5 October 31st 05 04:12 PM
Blinking Text Gordon C Excel Programming 1 December 7th 03 06:16 PM
Blinking Text? Wazza McG[_2_] Excel Programming 1 December 6th 03 09:59 PM


All times are GMT +1. The time now is 09:01 AM.

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"