Print an excel file from command line or "cron" type command ???

  • Thread starter Thread starter Chris Salcedo
  • Start date Start date
C

Chris Salcedo

I need to print an excel file at 3:15 every day. I would like to be
able to "schedule" it like in a cron job...(windows of course...) I
cant find any way to directly print from a comman line like "excel.exe
"c:\myfile.xls" /p

Any Ideas ????
 
If you can make sure that the Excel spreadsheet in questions is opened a
little before 3:15, then you can can put use Application.OnTime. eg

Private Sub Workbook_open()
application.onTime Date + TimeSerial(15,15,0), "PrintRoutine"
end sub

in a module:

Sub PrintRoutine()
dim sh as Object
for each sh in thisworkbook.Sheets
ws.printout
next sh
End Sub

Once the workbook is opened, it will do nothing until 3.15pm when it will
run PrintRoutine. It is worth saying that if you open this after 3.15pm it
will cause an error as the specified time is in the past.
 
This if from the VBA Help file using the OnTime method:

Application.OnTime TimeValue("17:00:00"), "my_Procedure"

It starts the macro at 5 P.M. Maybe you could use this.
 
Back
Top