![]() |
|
#1
|
||||
|
||||
![]() The following code intercepts the QAT printer button in Word 2007 & later, as well as the Ctrl-P print commands. Unfortunaltely, you can't intercept the File|Print command in Word 2007 & later, though this code will intercept it in earlier versions, too. The code looks for, then cuts out the document's first MACROBUTTON field before printing, then restores it after printing. Code:
Sub PrintPreviewAndPrint() Call FilePrint End Sub Sub FilePrintDefault() Call FilePrint End Sub Sub FilePrint() Application.ScreenUpdating = False Dim oFld As Field, Rng As Range With ActiveDocument For Each oFld In .Fields If oFld.Type = wdFieldMacroButton Then Set Rng = oFld.Result oFld.Cut Application.Dialogs(wdDialogFilePrint).Show Rng.Paste Exit For End If Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Debug for macro run through button only when sheet protected | leahca | Excel Programming | 0 | 11-24-2011 04:47 AM |
How do I assign a macro to a button when the macro is in my personal workbook? | foolios | Excel Programming | 2 | 07-27-2011 02:41 PM |
Word doc bug when closing from userform command button click macro | Joe Patrick | Word | 1 | 07-05-2011 08:53 PM |
![]() |
Joe Patrick | Word | 6 | 06-07-2011 09:31 AM |
Macro Button | B2W | Excel | 2 | 06-18-2010 09:36 AM |