PDA

View Full Version : Macro To Not Allow Printing When Specific Fields Are Left Blank



rachell_8
09-16-2010, 01:55 AM
Hi, can someone please help me create a macro on my file. I want the user to not be able to print the file unless he has filled-out the fields I have tagged in red font. I want an error message to prompt user that the required fields should be populated first before printing. Thanks! :help

Bob Phillips
09-16-2010, 03:55 AM
I have done a couple for you, I will leave the rest to you

rachell_8
09-16-2010, 04:07 AM
Perfect XLD!!! Thanks a lot for the help. You're the BEST!!! =D

rachell_8
09-16-2010, 04:07 AM
:clap:

NomalAnomaly
09-16-2010, 04:41 AM
Hey

In your WorkBook object, add the following code:


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If [SetOfConditions] Then
Cancel = False
Else
MsgBox 'Sorry, you cannot print at the moment.'
Cancel = True
End If
End Sub


Add the set of conditions you want to exist for the user to be able to print, in [SetOfConditions]. As long as these conditions are not met, printing will be disabled.

Hope this helped...
NormalAnomaly

rachell_8
09-16-2010, 07:49 PM
Thanks NormalAnomaly! :hi: