ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   schedule macro - application.OnTime (https://www.excelbanter.com/excel-programming/360959-schedule-macro-application-ontime.html)

ina

schedule macro - application.OnTime
 
Hello guys,

I would like to schedule a macros

So first of all I would like to open an external program from excel
calling PLauch, once the program open I would like to execute my macro
"operations" and once the macro finished I would like to save it
somewhere. But I am not very convinient with Application.Ontime and
schedule macro.

This is my code


Public Sub Workbook_Open()
On Error GoTo ErrHand

Dim dtmTime As Date
Dim dtmSave As Date

OpenPLaunch ' I launch the program


dtmTime = Now + TimeValue("00:00:15")
Application.OnTime dtmTime, "operations"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\test\test.xls", FileFormat:=xlHtml, ReadOnlyRecommended:=False,
CreateBackup:=False
'Application.DisplayAlerts = True
'dtmSave = dtmTime + TimeValue("00:01:00") 'I would like to have
the exact time after macro is finished
'Application.OnTime dtmSave, "Save_Exit"

ErrHand:
MsgBox "error"
End Sub

Sub operations()
Sheet1.Activate
Sheet1.GetInfo
Sheet2.Activate
Sheet2.AllClients

End Sub



Sub Save_Exit()
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End Sub

Could someone help me with this issue?

Thanks ina


Chip Pearson

schedule macro - application.OnTime
 
See www.cpearson.com/excel/ontime.htm for details and example
code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"ina" wrote in message
oups.com...
Hello guys,

I would like to schedule a macros

So first of all I would like to open an external program from
excel
calling PLauch, once the program open I would like to execute
my macro
"operations" and once the macro finished I would like to save
it
somewhere. But I am not very convinient with Application.Ontime
and
schedule macro.

This is my code


Public Sub Workbook_Open()
On Error GoTo ErrHand

Dim dtmTime As Date
Dim dtmSave As Date

OpenPLaunch ' I launch the program


dtmTime = Now + TimeValue("00:00:15")
Application.OnTime dtmTime, "operations"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\test\test.xls", FileFormat:=xlHtml,
ReadOnlyRecommended:=False,
CreateBackup:=False
'Application.DisplayAlerts = True
'dtmSave = dtmTime + TimeValue("00:01:00") 'I would like to
have
the exact time after macro is finished
'Application.OnTime dtmSave, "Save_Exit"

ErrHand:
MsgBox "error"
End Sub

Sub operations()
Sheet1.Activate
Sheet1.GetInfo
Sheet2.Activate
Sheet2.AllClients

End Sub



Sub Save_Exit()
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End Sub

Could someone help me with this issue?

Thanks ina




ina

schedule macro - application.OnTime
 
Thank you


Ina



All times are GMT +1. The time now is 04:22 AM.

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