MS Word 2007 - Prevent MacroButton from Printing

Hello,

 

I have a MacroButton on my document with a macro assingned to print only page 1 of the document.  Page 1 is where the macrobutton is located.  Can someone please tell me how to print this page without the gray macrobutton field showing?

 

Thank you

Answer
Answer
Glenn,

The code that Greg and I have suggested DOES NOT go inside the field, it goes in the macro that the original field runs.

Bit by bit:

  1. Remove the bookmark(s) and the MacroButton field that you have now.
  2. Insert a new copy of the original MacroButton field, {MACROBUTTON PrintPage1 PRINT} and press F9 to update the field -- now all you'll see is the word PRINT.
  3. Select the MacroButton field, including the brackets, and insert a bookmark named button. DO NOT DO ANYTHING ELSE TO THE MACROBUTTON FIELD.
  4. Open the macro editor (press Alt+F11) and look at the PrintPage1 macro (which should still be present, probably in the module named NewMacros). Note: It's important that the macro is stored in the document (or in a template different from Normal.dotm, if the document is based on that different template). If the macro is stored in Normal.dotm, you'll get an error if the macro is used with some other document that doesn't contain a bookmark named "button".
  5. Greg mentioned a MsgBox because he doesn't know exactly what command is in your macro. Assuming that you used the macro recorder, the macro probably looks like this:

Sub PrintPage1()
'
' PrintPage1 Macro
'
'
    Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="1", PageType:=wdPrintAllPages, _
         ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0
End Sub


Add the two lines I suggested, one before the Application.PrintOut line and the other before the End Sub line, so it looks like this:


Sub PrintPage1()
'
' PrintPage1 Macro
'
'

    ActiveDocument.Bookmarks("button").Range.Font.Hidden = True


    Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="1", PageType:=wdPrintAllPages, _
         ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0


    ActiveDocument.Bookmarks("button").Range.Font.Hidden = False

End Sub


Then save (Ctrl+S), close the macro editor, and try clicking the MacroButton field in the document. You should get page 1 printed without the button.



_____________________________
https://jay-freedman.info

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 1,296 Applies to: