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

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 ????
 
D

Deborah Digby

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top