![]() |
#1
|
|||
|
|||
![]()
Hello.
I'm trying to open a messagebox prompting a yes/no question when someone presses the print-icon in Word 2013. This is the code I've written: Code: Private Sub Workbook_BeforePrint(Cancel As Boolean)Dim Result As Long Result = MsgBox("Text", vbYesNo) If Result = vbNo Then Exit Sub Else ActiveDocument.PrintOut End If End Sub Sub FilePrintDefault() Dim Result As Long Result = MsgBox("Text", vbYesNo) If Result = vbNo Then Exit Sub Else ActiveDocument.PrintOut End If End Sub However, I can't get the code to fire. Some input on how to get the code to fire would be much appreciated. Thanks |
#2
|
||||
|
||||
![]()
You need two macros to intercept the Print commands in the document template e.g.
Code:
Sub FilePrintDefault() Dim Result As Long Result = MsgBox("Text", vbYesNo) If Result = vbNo Then Exit Sub Else ActiveDocument.PrintOut End If End Sub Sub FilePrint() Dim Result As Long Result = MsgBox("Text", vbYesNo) If Result = vbNo Then Exit Sub Else ActiveDocument.PrintOut End If End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
poetofpiano | Word VBA | 3 | 09-30-2017 11:59 PM |
Execute autocorrects? | KaiserD2 | Word | 6 | 04-03-2017 10:18 PM |
![]() |
npalmer610 | Word VBA | 1 | 04-12-2016 06:01 PM |
![]() |
smaddi | Mail Merge | 1 | 02-05-2012 02:45 AM |
![]() |
cksm4 | Word VBA | 1 | 10-22-2011 11:36 PM |