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.

Number of pages in Excel worksheets

Keywords: 	  Number of pages in Excel worksheets

; ///////////////////////////////////////////////////////////////////
; // Winbatch - Prior To Printing Excel Worksheets, this UDF       //
; //            indicates the number involved in each.             //
; //                                                               //
; //             Stan Littlefield, July 20, 2002                   //
; ///////////////////////////////////////////////////////////////////

#DefineFunction GetPages( cXLS )
   c                    = "WORKSHEET: "
   BoxOpen( "Calculating WorkSheet Printed Pages...",c )
   list                 = ""
   DB                   = ObjectOpen("Excel.Application")
   DB.Visible           = @FALSE
   DB.DisplayAlerts     = @FALSE
   oAPP                 = DB.Workbooks
   oAPP.Open("%cXLS%")
   oACT                 = DB.ActiveWorkbook
   Sheets               = oACT.WorkSheets
   n                    = Sheets.Count
   For i = 1 To n
      oWS               = DB.WorkSheets(i)
      oWS.Activate
      name              = oWS.Name
      BoxText( StrCat( c, name ) )
      HB                = oWS.HPageBreaks
      x                 = HB.Count +1
      VB                = oWS.VPageBreaks
      y                 = HB.Count +1
      list              = StrCat( list,name," Pages: ",x+y,@CRLF )
   Next
   ObjectClose(oWS)
   oACT.Close(:: SaveChanges = @FALSE )
   ObjectClose( oACT )
   ObjectClose(oAPP)
   DB.Quit
   ObjectClose(DB)
   BoxShut()
   message( "Printed Pages in %cXLS%",list )
Return( "" )
#EndFunction


cXLS                 = AskFilename( "Select Excel File For Printing", DirGet(), "XLS|*.XLS","*.XLS",1)
GetPages( CXLS )

Exit


Article ID:   W15637
File Created: 2003:05:13:11:29:20
Last Updated: 2003:05:13:11:29:20