Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Excel 2003 - Compile Error - Invalid Outside Procedure (https://www.askmehelpdesk.com/showthread.php?t=318026)

  • Feb 16, 2009, 11:13 AM
    RC4TXHVAC
    Excel 2003 - Compile Error - Invalid Outside Procedure
    Please Help! This is my first attempt at setting up a Macro in Excel 2003 and all I want to do is print out 8 worksheet pages with a macro.

    The first message I get says: "Unable to Record" Then I click on "OK" and it records the key strokes anyway! However, when I try to run it, I end up with that Compile Error Message. Thank you in advance for your assistance. Here is the Macro:

    Sub PrintALLpgs()
    '
    ' PrintALLpgs Macro
    ' Macro recorded 2/16/2009 x XXXXX
    '
    ' Keyboard Shortcut: Ctrl+Shift+P
    '
    Sheets("Cover").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("Energy").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("Equip").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("Repairs").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("Major").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("In-House").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("Summary").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("Notes").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    End Sub
  • Feb 16, 2009, 02:00 PM
    JBeaucaire

    Are there other pages to this workbook, or does this represent all the sheets in your workbook?

    This one line of code would replace all the individual sheets if that is the case:

    Code:

    Sub PrintALLpgs()
    '
    ' PrintALLpgs Macro
    ' Macro recorded 2/16/2009 x XXXXX
    '
    ' Keyboard Shortcut: Ctrl+Shift+P

        ActiveWorkbook.PrintOut Copies:=1, Collate:=True

    End Sub

  • Feb 16, 2009, 02:25 PM
    JBeaucaire

    Another idea, if you want to be able to flag certain sheets to print and other not to print and have a macro know which is which, this could do it.

    First, make sure your PRINT AREA is set on each sheet properly so they will look right. Then in the first cell putside the print area, put a value in a blank cell, lets choose M1.

    Then this macro will print every sheet that has any value in cell M1 on it. Change the cell reference if you want to use something else.
    Code:

    Sub PrintFlaggedSheets()
    Dim sht As Worksheet

    For Each sht In ThisWorkbook.Worksheets
      If sht.Range("M1").Value <> "" Then
            sht.PrintOut
        End If
    Next sht

    End Sub


  • All times are GMT -7. The time now is 03:50 AM.