I am trying to create a spread sheet that would require a person to fill in certain fields before they could print a worksheet. Is this possible?
I am trying to create a spread sheet that would require a person to fill in certain fields before they could print a worksheet. Is this possible?
Put the following code in the ThisWorkbook module
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Sheet1").Range("A1") = "" Then '<<< change as
required
Cancel = True
End If
End Sub
Change the worksheet name and cell reference to the appropriate
values.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"tiab86" <[email protected]>
wrote in message
news:[email protected]...
>
> I am trying to create a spread sheet that would require a
> person to fill
> in certain fields before they could print a worksheet. Is this
> possible?
>
>
> --
> tiab86
> ------------------------------------------------------------------------
> tiab86's Profile:
> http://www.excelforum.com/member.php...o&userid=25628
> View this thread:
> http://www.excelforum.com/showthread...hreadid=530950
>
Use the beforeprint event to check
If they are not filled in, then display a msgbox and set the cancel variable
to True.
http://www.cpearson.com/excel/events.htm
for an overview of events.
--
Regards,
Tom Ogilvy
"tiab86" wrote:
>
> I am trying to create a spread sheet that would require a person to fill
> in certain fields before they could print a worksheet. Is this possible?
>
>
> --
> tiab86
> ------------------------------------------------------------------------
> tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
> View this thread: http://www.excelforum.com/showthread...hreadid=530950
>
>
Ok,
I'm a bit confused.
When I put the values in below it appears to do nothing.
I'm new to VB so that's probably part of my problem.
What am I doing wrong?
I get the following error:
Run-time error '438':
Object doesn't support this property or method
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Packing Slip").Range("U10") = "" Then '
Cancel = True
End If
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Packing Slip").Range("U10") = "" Then '
Cancel = True
End If
End Sub
You have already hit the print button, so you don't need to do anything for
it to print. What you are doing is cancelling that print if U10 of Packing
Slip is blank.
Immediately after Cancel=True you might want to put in
Msgbox "Printing cancelled until you put a value in U10"
--
Regards,
Tom Ogilvy
"tiab86" wrote:
>
> Ok,
> I'm a bit confused.
> When I put the values in below it appears to do nothing.
> I'm new to VB so that's probably part of my problem.
> What am I doing wrong?
> I get the following error:
>
>
> Run-time error '438':
> Object doesn't support this property or method
>
>
> Private Sub Workbook_BeforePrint(Cancel As Boolean)
> If Worksheets("Packing Slip").Range("U10") = "" Then '
> Cancel = True
> End If
> End Sub
>
>
> --
> tiab86
> ------------------------------------------------------------------------
> tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
> View this thread: http://www.excelforum.com/showthread...hreadid=530950
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks