Showing posts with label Excel. Show all posts
Showing posts with label Excel. Show all posts

Sunday, April 1, 2007

Excel Files Printing Automation

On Error Resume Next

Dim LoadDelay, QuitDelay
'Time to wait in ms(millisecond, 1 second=1000ms)
LoadDelay = 1000
QuitDelay = 1000

If (WScript.Arguments.Count = 1) Then
ExcelFileName = WScript.Arguments.Item(0)
Else
ExcelFileName = InputBox("Please Enter the Excel File Name > ")
End If

Set objExcel = WScript.CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.Workbooks.Open(ExcelFileName)
WScript.Sleep LoadDelay

'Print to the default printer
'Print the first sheet, sheet index starts from 1
'Set ObjSheet = objExcel.ActiveWorkbook.WorkSheets(1)
'ObjSheet.PrintOut

'Print all sheets in the workbook
objExcel.ActiveWorkbook.PrintOut

WScript.Sleep QuitDelay

objExcel.ActiveWorkbook.Close(False)

objExcel.Quit

 
visitors since March 26 2007
©2007