Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Suppress printing using button


I currently have the following macro to suppress printing and it almost
works perfectly:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Information contained in this workbook cannot be printed"
End Sub

The problem is that some individuals (who do not have edit privileges)
may need to print a worksheet before sending the workbook to the end
user (who cannot print anything).

Those users who have edit privileges are currently using a "lock
button" to lock specific cells throughout the workbook from being
edited by the end users. Can this print macro be somehow assigned to
the same button that I'm using to lock cells? I've tried to do this but
it doesn't seem to work. (FYI: If it helps, here is the macro I recorded
in a module to lock the cells):
Sheets("T133B").Select
Range("A1:M133").Select
ActiveWindow.ScrollRow = 1
Selection.Locked = True
Selection.FormulaHidden = False
Range("C4:J4").Select
Sheets("T133A").Select
Range("C3:M44").Select
ActiveWindow.ScrollRow = 12
Selection.Locked = True
Selection.FormulaHidden = False
Range("C5").Select
Sheets("T133A 2nd").Select
Range("C5:M44").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range("C5").Select
Sheets("DLO").Select
ActiveWindow.ScrollRow = 1
Range("C5:M77").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range("C5").Select
End Sub


--
zenahs
------------------------------------------------------------------------
zenahs's Profile: http://www.excelforum.com/member.php...o&userid=28681
View this thread: http://www.excelforum.com/showthread...hreadid=509012

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Suppress printing using button

Do you mean you don't want the macro created until they lock the cells. If
so, see Chip Pearson's page on writing code with code

http://www.cpearson.com/excel/vbe.htm

Unfortunately you can not record the creation of the code. You should also
check if the code already exists in case the button is pressed more than
once (or get rid of the button).

You could have a working workbook and then have your button copy only what
is appropriate to a "package" workbook that already has the print macro in
it. It could then do final modifications and then save the workbook.
This "package" workbook would be sent to the customer.

Just note that an smart customer could run code/a macro from another
workbook in which the code disables events and then repeatedly print your
workbook. Code based protection is generally so weak (as is all Excel
based protection) that it is generally not worth the effort.

--
Regards,
Tom Ogilvy


"zenahs" wrote in
message ...

I currently have the following macro to suppress printing and it almost
works perfectly:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Information contained in this workbook cannot be printed"
End Sub

The problem is that some individuals (who do not have edit privileges)
may need to print a worksheet before sending the workbook to the end
user (who cannot print anything).

Those users who have edit privileges are currently using a "lock
button" to lock specific cells throughout the workbook from being
edited by the end users. Can this print macro be somehow assigned to
the same button that I'm using to lock cells? I've tried to do this but
it doesn't seem to work. (FYI: If it helps, here is the macro I recorded
in a module to lock the cells):
Sheets("T133B").Select
Range("A1:M133").Select
ActiveWindow.ScrollRow = 1
Selection.Locked = True
Selection.FormulaHidden = False
Range("C4:J4").Select
Sheets("T133A").Select
Range("C3:M44").Select
ActiveWindow.ScrollRow = 12
Selection.Locked = True
Selection.FormulaHidden = False
Range("C5").Select
Sheets("T133A 2nd").Select
Range("C5:M44").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range("C5").Select
Sheets("DLO").Select
ActiveWindow.ScrollRow = 1
Range("C5:M77").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range("C5").Select
End Sub


--
zenahs
------------------------------------------------------------------------
zenahs's Profile:

http://www.excelforum.com/member.php...o&userid=28681
View this thread: http://www.excelforum.com/showthread...hreadid=509012



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
suppress printing on certain rows Valerie Excel Discussion (Misc queries) 7 April 30th 09 07:49 PM
Does anyone know if I can suppress footers when printing? BPC123 Excel Discussion (Misc queries) 2 September 23rd 08 05:15 PM
Suppress printing of row shading Bob Arnett Excel Discussion (Misc queries) 1 April 15th 08 08:48 PM
How do I suppress printing a row without hiding it? ejt1234 Excel Discussion (Misc queries) 5 October 27th 07 03:23 AM
Suppress printing workbook zenahs Excel Discussion (Misc queries) 2 February 6th 06 08:49 PM


All times are GMT +1. The time now is 09:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"