Ask Experts Questions for FREE Help !
Ask
    RC4TXHVAC's Avatar
    RC4TXHVAC Posts: 1, Reputation: 1
    New Member
     
    #1

    Feb 16, 2009, 11:13 AM
    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
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    Feb 16, 2009, 02:00 PM

    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
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #3

    Feb 16, 2009, 02:25 PM

    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

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Error 1327. Invalid Drive E:\ [ 10 Answers ]

I recently removed a second hard drive from my computer (Dell w/ Windows XP). Now I cannot install or uninstall programs because the drive path (E) is no longer there. I get an error message: Error 1327. Invalid Drive E:\. I disabled the drive in the setup utility and it is no longer visible in...

Compile error with excel 2007 [ 2 Answers ]

I have written a very basic Macros code to retrieve a photo off my server. I want it to run this macro when a person has selected a certain item off a drop down list. The problem I am having is that when I try and run the macro manually or when the workbook opens I get a an error message that...

Excel 2007 to have excel 2003 look? [ 6 Answers ]

Hey I have Microsoft Excel 2007, from my course at college I have been given instructions to do a task. However these instructions are for excel 2003. How do I change my excel 07 to look like excel 03 so that it is easier. I know there is a way, help greatly appreicated thanks.

Error 1327 Invalid Drive E when Trying to Remove A Program [ 1 Answers ]

I am donating two laptops to charity and am trying to clean them up first by uninstalling a lot of unnecessary software and then using a wiping program to wipe personal data. However, when I try to remove some of the programs using Windows XP's "Add or Remove Programs" function, I get an Error...


View more questions Search