|
Answer» Is there a way to automatically PRINT a spread sheet from an Excel file with a batch (.bat) file?do you WANT to print to a printer? or just print the data to screen. here's a vbscript to print to screen. Code: [Select]Option Explicit Dim objExcel,excelPath,worksheetCount Dim counter,currentWorkSheet, usedRowsCount,row Dim column,top, left, Cells, curCol,curRow,WORD excelPath = "C:\test\Book1.xls" Set objExcel = CreateObject("Excel.Application") objExcel.Workbooks.open excelPath, FALSE, true workSheetCount = objExcel.Worksheets.Count For counter = 1 to workSheetCount Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets(counter) usedColumnsCount = currentWorkSheet.UsedRange.Columns.Count usedRowsCount = currentWorkSheet.UsedRange.Rows.Count top = currentWorksheet.UsedRange.Row left = currentWorksheet.UsedRange.Column Set Cells = currentWorksheet.Cells For row = 0 to (usedRowsCount-1) For column = 0 to usedColumnsCount-1 curRow = row+top curCol = column+left word = Cells(curRow,curCol).Value WScript.Echo (word) Next Next Set currentWorkSheet = Nothing Next objExcel.Workbooks(1).Close objExcel.Quit Set currentWorkSheet = Nothing Set objExcel = Nothing
|