WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Print All Sheets in a WorkBook

 Keywords: Print WorkSheets WorkSheet WorkBook Excel OLE

Sample Code:

objExcel=ObjectOpen("Excel.Application")

; DisplayAlerts Property - The default value is True. Set this property to False if you don’t want to be disturbed by prompts 
; and alert messages while a macro is running; any time a message requires a response, Microsoft Excel chooses the default response.
objExcel.DisplayAlerts = @FALSE

; ScreenUpdating Property -Turn screen updating off to speed up your macro code. You won't be able to see what the macro is doing, 
; but it will run faster.
objExcel.ScreenUpdating = @FALSE

; AskToUpdateLinks Property - @True if Microsoft Excel asks the user to update links when opening files with links. 
; @False if links are automatically updated with no dialog box. 
objExcel.AskToUpdateLinks = @FALSE

objWB=objExcel.Workbooks
objWB.Open("C:\TEMP\BPR.XLS")

objsheets = objExcel.Worksheets
cnt = objsheets.count

For i = 1 to cnt
 thissheet=ObjExcel.WorkSheets(i)
 thissheet.Visible = @TRUE ;Sets Sheet Visible (in case its hidden)
 thissheet.Printout()
Next

; Grab the active workbook
objWorkbookActive = objExcel.ActiveWorkbook

; Close Method - Named parameter "SaveChanges", this argument specifies whether changes should be saved.
; @False - Does not save the changes to this file. If Omitted, this Displays a dialog box asking the user 
; whether or not to save changes. 
objWorkbookActive.Close(::SaveChanges=@False)

objExcel.Quit
ObjectClose(objExcel)
Message("All","Done")

Article ID:   W15255
File Created: 2002:09:05:13:50:52
Last Updated: 2002:09:05:13:50:52