ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing at certain times of a day (https://www.excelbanter.com/excel-programming/337034-printing-certain-times-day.html)

NelsonPG

Printing at certain times of a day
 
I'm looking to see if I can print a sheet in excel 2003 at certain times
during a 24 hour period. I have collected Data and would like it to print the
sheet without someone having to be there.

K Dales[_2_]

Printing at certain times of a day
 
The OnTime event can be used to schedule a procedure to run. The worksheet
would have to be running (at least in the background) continually, but here's
what you could do. You would need to run a procedure to "trigger" the whole
thing - this could be a macro you run manually or if desired could be the
Workbook_Open event procedure. It just needs to set up the time for printing
and call the Application.OnTime method. With Application.OnTime you specify
"by name" the procedure you want to run and when it should happen; the whole
thing could look something like this (I will set it up to print every 6 hours
starting 6 am):

Sub Workbook_Open()
Dim TimePeriod as Integer, TimeToPrint as Date
TimePeriod = Int(Hour(Now())/6)+1
TimeToPrint =
TimeValue(Choose(TimePeriod,"06:00:00","12:00:00", "18:00:00","23:59:59"))
Application.OnTime TimeToPrint, "TimedPrint"
End Sub

Sub TimedPrint()
ThisWorkbook.Printout
Application.Wait (Now()+10) ' Just to make sure we are into the next time
period
Call Workbook_Open()
End Sub

If you need to you can cancel the OnTime procedure that is next scheduled to
run by
Application.OnTime TimeToPrint, "TimedPrint", , False

--
- K Dales


"NelsonPG" wrote:

I'm looking to see if I can print a sheet in excel 2003 at certain times
during a 24 hour period. I have collected Data and would like it to print the
sheet without someone having to be there.



All times are GMT +1. The time now is 06:55 PM.

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