Results 1 to 3 of 3

Thread: Print button macro

  1. #1
    Seeker GregT's Avatar
    Join Date
    Nov 2019
    Posts
    5
    Articles
    0
    Excel Version
    2016

    Print button macro



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi all,

    I have a workbook with 4 sheets - 2 are hidden. The following code I am using works with the hidden sheet.

    The problem is when I protect the sheets and workbook I get an error when I try to print the protected sheet or workbook. Can you suggest a workaround? Also I would like to view before print if that is possible...

    TIA GT
    ----------------------------------------------------------------

    Sub PrintSpecificSheet()
    Dim wks As Worksheet

    Set wks = ActiveWorkbook.Sheets("Printout")
    If wks.Visible <> xlSheetVisible Then
    Application.ScreenUpdating = False
    wks.Visible = xlSheetVisible
    wks.PrintOut
    wks.Visible = xlSheetHidden
    Application.ScreenUpdating = True
    Else
    wks.PrintOut
    End If
    Set wks = Nothing
    End Sub
    Last edited by GregT; 2019-11-16 at 03:12 PM.

  2. #2
    Super Moderator Bob Phillips's Avatar
    Join Date
    Mar 2011
    Posts
    1,681
    Articles
    0
    Excel Version
    O365
    In your VBA, unprotect the sheet, print it, then re-protect.

  3. #3
    Seeker GregT's Avatar
    Join Date
    Nov 2019
    Posts
    5
    Articles
    0
    Excel Version
    2016
    thanks

Posting Permissions

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