+ Reply to Thread
Results 1 to 9 of 9

View but not print out

Hybrid View

  1. #1
    Registered User
    Join Date
    10-19-2008
    Location
    Western Australia
    Posts
    19

    View but not print out

    G'day All,

    Does anyone know if there's a way to either define what columns or rows are printable or to somehow leave columns (or rows) as visible within the print area but omitted from printing as if they were hidden.

    In my CAD package I can simply elect to have certain collections of information "non-printable", is there any way I can do this with columns without having to rely on people managing to laboriously (sic) hide and unhide columns either side of printing a document.

    Some of the information is too sensitive to risk being inadvertantly sent out.(We've all heard of it happening)

    Cheers

    Clive
    Last edited by Aussie-Clive; 08-17-2009 at 06:12 AM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: View but not print out

    Good afternoon Aussie-Clive

    Generally, Excel will print whatever is set within the print range. The simplest way would be to have a macro that (could be easily recorded by the macro recorder) would hide any rows / columns and then sent to the printer. That would sort out the laborious bit. You could also have a piece of code that is fired by the print event, so when someone attempts to send something to the printer, several rows / columns hidden status is checked and if they aren't hidden then a confirm message is flashed up and the operation is aborted. Would something like this be acceptable?

    You could also lump these two pieces of code together, but that would remove an element of control, making it tricky if you actually wanted to print out these rows / columns on occasion.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    10-19-2008
    Location
    Western Australia
    Posts
    19

    Re: View but not print out

    Thanks for the ideas Dominic,

    What you suggest is certainly acceptable, though it's a pity there isn't a more straightforward solution.

    Though I'm happy to tackle coding - I certainly couldn't be credited with any competence!

    How would I go about structuring this and in what form is the print event referenced?

    Cheers

    Clive

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: View but not print out

    You can set print area outside parameters you see.

    For example your data is from column A to column D but you want to print C and D -> just set prin area at that part of sheet.
    Never use Merged Cells in Excel

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: View but not print out

    Hi Aussie-Clive

    This would be a starting point. It needs to go into the ThisWorkbook module of the VBE (press Alt + F11 to open the VBE). It's a simple check that will intercept the printer call and make the decision whether or not to print : if column "D" and row "10" are visible, then the printer call is aborted, otherwise the document will be sent to the printer :
    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If Columns("D:D").EntireColumn.Hidden = False Or _
       Rows("10:10").EntireRow.Hidden = False Then
    MsgBox "Rows are not hidden"
    Cancel = True     'This statement cancels the print command
    Exit Sub
    End If
    End Sub
    As I say, it's a starting point and can be refined further according to any suggestions you might want to make.

    HTH

    DominicB

  6. #6
    Registered User
    Join Date
    10-19-2008
    Location
    Western Australia
    Posts
    19

    Re: View but not print out

    My brain seems to be in Sunday-mode, I can't seem to get that to work.

    Can you explain for the hard of thinking how I do this after the Alt-F11 as I've clearly got something wrong!

    Not enough Chorley cakes perhaps?

    Cheers

  7. #7
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: View but not print out

    Hi Aussie-Clive
    Quote Originally Posted by Aussie-Clive View Post
    Can you explain for the hard of thinking how I do this after the Alt-F11 as I've clearly got something wrong!
    From Excel, plress Alt + F11. This will open the VBE.
    From the Project - VBA Project window on the left find your file.
    Double click on the This Workbook object. This will open a new pane.
    Paste your code into this pane.
    Go to File > Close and Return to Microsoft Excel.

    HTH

    DominicB

  8. #8
    Registered User
    Join Date
    10-19-2008
    Location
    Western Australia
    Posts
    19

    Re: View but not print out

    Brilliant, Thanks All.

    Sorry Dominic, I didn't have the project pane visible and couldn't figure it out as this isn't my area. appreciate your patience. It all works well and I'm sure I can figure it out from here. I also like Martins lateral thinking.

    I still feel that this is an area that MS could possibly improve on, by having a print / non print definition built in - as I say we all know of someone who has tripped over their own shoelaces printing confidential information in error, so it's not like it's an uncommon problem.

    I'll mark it as solved and thanks again.

    Cheers from Oz.

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: View but not print out

    just another suggestion if its always the same columns you want to hide
    make another sheet called print
    reference all the columns you want on it set print area
    and only use that sheet for printing
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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