Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-22-2012, 10:11 PM
macropod's Avatar
macropod macropod is offline Assign macro but hide the button/field Windows 7 64bit Assign macro but hide the button/field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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
 

Thread Tools
Display Modes


Similar Threads
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
Assign macro but hide the button/field Button in hidden section won't hide Joe Patrick Word 6 06-07-2011 09:31 AM
Macro Button B2W Excel 2 06-18-2010 09:36 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:36 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft