+ Reply to Thread
Results 1 to 3 of 3

Error using a macro to print multiple pages.

  1. #1

    Error using a macro to print multiple pages.

    Hello,

    I am fairly new to all this macro stuff. I have a macro that keeps
    giving me an error only after I place protections on the sheets and
    workbook. The macro is triggered by a command button (commandButton1).
    The third page in my script is hidden, the other two are not. Ranges
    are defined on the first two and they print just fine. Third one has a
    formula which used to work but doesn't now. I have tried to figure out
    why it has gone awry, and failed. Any help would be appreciated. Here
    is the code:


    Private Sub CommandButton1_Click()

    ' Hide_Print_Unhide Macro
    ' Macro recorded 5/5/2006 by Robert Lizak
    '
    Dim cell As Range
    Dim myPwd As String


    myPwd = "secret"


    Application.ScreenUpdating = False

    Sheets("Stats").PageSetup.PrintArea = "$A$1:$R$46"
    Sheets("Stats").PrintPreview

    Sheets("Equipment & Background").PageSetup.PrintArea = "$A$1:$F$46"
    Sheets("Equipment & Background").PrintPreview

    Sheets("Print Sheet").Active
    ActiveSheet.Unprotect Password:=myPwd
    Sheets("Print Sheet").Visible = True
    With Sheets("Print Sheet")
    For Each cell In .Range("A1:A712")
    If cell.Value = "" Then cell.EntireRow.Hidden = True
    Next cell
    .PrintPreview
    .Range("A1:A712").EntireRow.Hidden = False
    .Visible = False
    ActiveSheet.Protect Password:=myPwd
    End With
    Application.ScreenUpdating = True
    '
    End Sub

    runtime error '438'
    Object doesn't support this property or method.


    -Robert Lizak-


  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Quote Originally Posted by [email protected]
    Sheets("Print Sheet").Active
    Try changing above to Sheets("Print Sheet").Activate

  3. #3

    Re: Error using a macro to print multiple pages.


    Mallycat wrote:
    > Try changing above to Sheets("Print Sheet").Activate


    Thanks... You know, maybe I oughtta use a spell check more frequently.

    -Robert Lizak-


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1