ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   button on a timer (https://www.excelbanter.com/excel-programming/367722-button-timer.html)

[email protected]

button on a timer
 
i'm writting a little something in excel and i need to have a button
(visual basic form type) pressed every 3 minutes...any suggestions?


Jim Thomlinson

button on a timer
 
Change the scope of the button from private to public and then write a
recursive sub to call the button click porcedure. Something like this

'**** In a standard code module
Public Sub PressTheButton()
Application.OnTime Now() + TimeSerial(0, 0, 10), "PressTheButton"
Call Sheets("Sheet1").CommandButton1_Click
End Sub

'**** In the Worksheet
Public Sub CommandButton1_Click()
MsgBox "Tada"
End Sub
--
HTH...

Jim Thomlinson


" wrote:

i'm writting a little something in excel and i need to have a button
(visual basic form type) pressed every 3 minutes...any suggestions?



[email protected]

button on a timer
 
I get the error:

"Object doesn't support this property or method"

for the
Call Sheets("Sheet1").CommandButton1_Click

help!



Jim Thomlinson wrote:
Change the scope of the button from private to public and then write a
recursive sub to call the button click porcedure. Something like this

'**** In a standard code module
Public Sub PressTheButton()
Application.OnTime Now() + TimeSerial(0, 0, 10), "PressTheButton"
Call Sheets("Sheet1").CommandButton1_Click
End Sub

'**** In the Worksheet
Public Sub CommandButton1_Click()
MsgBox "Tada"
End Sub
--
HTH...

Jim Thomlinson


" wrote:

i'm writting a little something in excel and i need to have a button
(visual basic form type) pressed every 3 minutes...any suggestions?




Jim Thomlinson

button on a timer
 
That exact code works for me. Did you rememeber to change the scope of the
click procedure?

'Note the key word Public (not Private)
Public Sub CommandButton1_Click()
--
HTH...

Jim Thomlinson


" wrote:

I get the error:

"Object doesn't support this property or method"

for the
Call Sheets("Sheet1").CommandButton1_Click

help!



Jim Thomlinson wrote:
Change the scope of the button from private to public and then write a
recursive sub to call the button click porcedure. Something like this

'**** In a standard code module
Public Sub PressTheButton()
Application.OnTime Now() + TimeSerial(0, 0, 10), "PressTheButton"
Call Sheets("Sheet1").CommandButton1_Click
End Sub

'**** In the Worksheet
Public Sub CommandButton1_Click()
MsgBox "Tada"
End Sub
--
HTH...

Jim Thomlinson


" wrote:

i'm writting a little something in excel and i need to have a button
(visual basic form type) pressed every 3 minutes...any suggestions?






All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com