MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Printing/viewing restrictions

Posted by Fran on May 10, 2001 9:57 AM

I posted this earlier, but I am not sure if I explained myself correctly - so here goes. :)

I have a workbook that has columns A through AE. I need columns B through E to be seen but not printed or seen if emailed.

To try to be more specific, I need the columns and the information to show up only when viewing it or adding additional information to the sheet, but if someone tries to print it, or email it to anyone, I need for the data in those columns to be "invisible." I have tried using the "protect function" but am having a really hard time.

Is that possible?

Posted by Dax on May 11, 2001 2:26 PM

Preventing someone from seeing something when printing is easy enough. Click Alt+F11 in your workbook and paste this:-

Private Sub Workbook_BeforePrint(Cancel As Boolean)
End Sub

Sub PrintWithHide()
Columns("B:H").Hidden = True
Columns("B:H").Hidden = False
End Sub

This will hide columns B-H when someone tries to print out the worksheet.

As for preventing someone from seeing columns when the spreadsheet is sent, may I suggest that you disable the menu options that allow the sending of the workbook and include a custom option that includes code like above.


PS I'm drunk right now.

Posted by Fran on May 21, 2001 5:15 PM

Posted by Fran on May 22, 2001 9:16 AM

LOL...well I hope you had an enjoyable drunk! In any case, it doesn't work. when I print it out, those columns are still there.

Do you have any ideas as to what could be wrong - seeing how you were drunk and everything. :)