ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Aborting from a "Before Print" Event (https://www.excelbanter.com/excel-programming/294822-aborting-before-print-event.html)

Hotbird[_2_]

Aborting from a "Before Print" Event
 
What i am trying to do is to intercept a User's print instruction, and add a
message box asking a question, and depending upon the answer, either
allowing the Print to proceed, or abort. Unfortunately Exit Sub, End, or
Stop does not prevent execution of the Print command. What line can I
insert in the following to abort the print?

Private Sub Workbook_BeforePrint(Cancel As Boolean)

End Sub



Bob Phillips[_6_]

Aborting from a "Before Print" Event
 
Set the Cancel argument to True

ans=MgBox "Yes or NO",vbYesNO
if ans = vbNo then
Cancel = True
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hotbird" wrote in message
news:Krtec.15636$4N3.13858@newsfe1-win...
What i am trying to do is to intercept a User's print instruction, and add

a
message box asking a question, and depending upon the answer, either
allowing the Print to proceed, or abort. Unfortunately Exit Sub, End, or
Stop does not prevent execution of the Print command. What line can I
insert in the following to abort the print?

Private Sub Workbook_BeforePrint(Cancel As Boolean)

End Sub






All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com