View Single Post
 
Old 02-22-2012, 10:11 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote