![]() |
#1
|
|||
|
|||
![]() I have a test where I've created a macro that will hide the answers (all text between brackets). I can assign the macro to a field so it runs upon double click or to a button, but can't figure out how to I make it so they run the macro to hide the answers and print the test "without" the field or button printing too. I like using the field macro better because you can undo and bring the answers back but would like to hide it upon printing. Any help is appreciated. Thanks! ![]() |
#2
|
||||
|
||||
![]()
Hi trlear,
I hate to rain on your parade, but nothing a macro does to hide text can prevent its display or printing - toggling the display is as simple as pressing the ¶ symbol on the Home tab, and printing them is as simple as checking a print option. As for your 'field button', if it's a MACROBUTTON field, that could be hidden, but a formfield can't.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
I do have the macro assigned to the MACROBUTTON field. I want the user to see the "Click here to remove answers" but I just don't want it to print when they print the document out.
|
#4
|
||||
|
||||
![]()
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] |
#5
|
|||
|
|||
![]()
I'm not sure what on earth some of the code means, but it's awesome!
![]() ![]() |
#6
|
||||
|
||||
![]()
If you're saving your document as a template, with the code I've given you, you could save a QAT customization in that template also. That way, the customized QAT will be available whenever a document based on that template is used.
__________________
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 |