Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2012, 09:51 AM
trlear trlear is offline Assign macro but hide the button/field Windows 7 32bit Assign macro but hide the button/field Office 2010 32bit
Novice
Assign macro but hide the button/field
 
Join Date: Feb 2012
Posts: 3
trlear is on a distinguished road
Default Assign macro but hide the button/field


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!
Reply With Quote
  #2  
Old 02-22-2012, 03:13 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: 21,956
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

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]
Reply With Quote
  #3  
Old 02-22-2012, 03:20 PM
trlear trlear is offline Assign macro but hide the button/field Windows 7 32bit Assign macro but hide the button/field Office 2010 32bit
Novice
Assign macro but hide the button/field
 
Join Date: Feb 2012
Posts: 3
trlear is on a distinguished road
Default

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.
Reply With Quote
  #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: 21,956
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
  #5  
Old 02-23-2012, 08:14 AM
trlear trlear is offline Assign macro but hide the button/field Windows 7 32bit Assign macro but hide the button/field Office 2010 32bit
Novice
Assign macro but hide the button/field
 
Join Date: Feb 2012
Posts: 3
trlear is on a distinguished road
Default

I'm not sure what on earth some of the code means, but it's awesome! And it worked like a charm. The only thing to do now is to teach my guys to use the print preview button instead of the File/Print. A couple of them barely know how to run a computer. While I"m here would u also know how to get the QAT buttons to follow a document. If I make a macro button for "This document" it disappears when anyone esle opens it from another machine. Just checking. Otherwise I can make a new thread. Thanks a BUNCH for your help!
Reply With Quote
  #6  
Old 02-23-2012, 04:35 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: 21,956
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

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

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 05:23 AM.


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