Saturday, May 2, 2009

Print Odd and Even pages in Excel

In Microsoft Word, we have an option of printing Even and Odd pages which helps in saving paper by printing on both sides. But the same option does not exist in Excel.

One can add the following VBScript in Macros of the Excel workboook and print Odd or Even pages.
---------------------------------------------------------------------------------
Sub printalterantepages()
    Dim Totalpages As Long
    Dim StartPage As Long
    Dim Page As Integer

    StartPage = 1  '1 = Odd and 2 = Even

    'Or use the InputBox suggestion from Gord Dibben
    'StartPage = InputBox("Enter 1 for Odd, 2 for Even")

    Totalpages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
    For Page = StartPage To Totalpages Step 2
        ActiveSheet.PrintOut from:=Page, To:=Page, _
                             Copies:=1, Collate:=True
    Next
End Sub
------------------------------------------------------------------------------------------------
As stated in the code, one has to change the StartPage value from 1 to 2 to print Odd and then Even pages.

Print Odd and Even pages in ExcelSocialTwist Tell-a-Friend
Bookmark and Share
Blog Widget by LinkWithin
 
Clicky Web Analytics