Command button with timer
Hi;
I have n button that executes the application obviously, but what I want to do is set a timer so that the timer
execute the application every 15 minutes so I don’t know how to link the command button to the timer if it is possible
Code:
Private Sub cmdstart_Click()
If lblMsgA >= 1000 Then
Dim oleasApp As Outlook.Application
Set oleasApp = CreateObject("Outlook.Application")
Dim oleasNs As Outlook.Namespace
Set oleasNs = oleasApp.GetNamespace("MAPI")
oleasNs.Logon
Dim oleasMail As Outlook.MailItem
Set oleasMail = oleasApp.CreateItem(oleasMailItem)
oleasMail.To = " @ "
oleasMail.Subject = "VB TEST"
oleasMail.Body = _
"Bla Bla" & ", " & vbCr & vbCr & vbTab & _
"Bla ." & ", " & vbCr & vbCr & vbTab & _
"Bla"
oleasMail.Send
MsgBox "All done...", vbMsgBoxSetForeground
oleasNs.Logoff
Set oleasNs = Nothing
Set oleasMail = Nothing
Set oleasApp = Nothing
End If
‘Timer’
Dim MinCount As Integer()
Sub tmrMinute_Timer()
MinCount = MinCount + 1
If (MinCount = 15) Then
cmdstart ( DON’T KNOW THIS PART CAN IT BE DONE like this..
MinCount = 0
End If
End Sub
1 Attachment(s)
Re: Command button with timer
dear, can this help?
form with : command = cmdstart
timer1 and label1
!! set timer1 Interval to 1000 millisec. ( = 1 sec.) as fast control !!!
===================================
Option Explicit
Dim MinCount As Integer
Private Sub cmdstart_Click()
If lblMsgA >= 1000 Then
Dim oleasApp As Outlook.Application
Set oleasApp = CreateObject("Outlook.Application")
Dim oleasNs As Outlook.Namespace
Set oleasNs = oleasApp.GetNamespace("MAPI")
oleasNs.Logon
Dim oleasMail As Outlook.MailItem
Set oleasMail = oleasApp.CreateItem(oleasMailItem)
oleasMail.To = " @ "
oleasMail.Subject = "VB TEST"
oleasMail.Body = _
"Bla Bla" & ", " & vbCr & vbCr & vbTab & _
"Bla ." & ", " & vbCr & vbCr & vbTab & _
"Bla"
oleasMail.Send
MsgBox "All done...", vbMsgBoxSetForeground
oleasNs.Logoff
Set oleasNs = Nothing
Set oleasMail = Nothing
Set oleasApp = Nothing
End If
End Sub
Sub tmrMinute_Timer()
'§ set timer1 Interval=min. => 60000 millisec. !!
MinCount = MinCount + 1
'§ as temporary control
Label1.Caption = MinCount
If (MinCount = 15) Then
Call cmdstart_Click
MinCount = 0
End If
End Sub
===================================
Re: Command button with timer
Thanks got confuse with the “Call cmdstart_Click” part