Link to home
Start Free TrialLog in
Avatar of Michael Vasilevsky
Michael VasilevskyFlag for United States of America

asked on

Word form with Command Button - Don't Show on Print

I have a Word 2007 doc with command buttons which I do not want to show when the document is printed.
Is this possible?
Thx,

MV
Avatar of BigBadWolf_000
BigBadWolf_000
Flag of United States of America image

Make sure you are in Design Mode  the Design Mode button on the top-left of the Control Toolbox toolbar needs to be depressed.

Now, double-click on the CommandButton  this will take you into the VBE (Visual Basic Editor) and create a CommandButton_Click event procedure. Paste the following code into this procedure.

Close the VBE, exit out of Design Mode and the CommandButton should not print
Private Sub CommandButton1_Click() 
 
With ActiveDocument 
    .Shapes(1).Visible = msoFalse 
    .PrintOut Background:=False 
    .Shapes(1).Visible = msoTrue 
End With 
 
End Sub

Open in new window

Oh in Word 2007
Open file make sure macros are enabled
Click on Developer Tab
In ribbion click on Design Mode

Avatar of Michael Vasilevsky

ASKER

hmm I think you misunderstood, that code prints the document on the Click event. I want to set the "VisibleOnPrint" property of the command button to False so that it doesn't show up when a user manually prints the document. Does the "VisibleOnPrint" property exist in Word?

I know Access has the "Display When (Always, Print Only, Screen Only)" property for form controls. I'm looking for something analogous here, so I can display the command button on the screen only (not on print).
I hope that's clearer.
The above code....prints the document on the Click event. However, it will not print the button itsself on the print output. Try it on the test file, you will see what I mean.


It did print the button...
Make sure this "CommandButton1_Click()" is changes to the appropiate (name) on your button properties. If you do Wors > File > Print it will print the button . If you click on the button it will not print the button. Sorry I cant post my file, site does not allow any xml, zipped or renamed :(

Here are some images...Hope this helps
Snap1.jpg
Snap2.jpg
Snap3.jpg
Ok I see the code is for a 'Print Document' command button. I don't want to force my users to print from a custom button and don't think I could get them to comply anyway. So there is no command button property like what I'm looking for?
Ahhhh..I now understand.... I believe in Excel there is the option of changing "print object" (for the command button) to False and then the button does not print when the
worksheet is printed. But in Word, i am not sure.

However, if you place a macro button in the toolbar it should not print. Check out this link on how to...towards the end of the page
http://www.gmayor.com/installing_macro.htm
Hope this helps
ASKER CERTIFIED SOLUTION
Avatar of Michael Vasilevsky
Michael Vasilevsky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was too simple. Thanks, I learnt something.
Avatar of scarysc
scarysc

dragging up an old thread but how do I apply "hidden"? to the cmd button?
Word 2007: In design mode right-click on cmd button, select CommandButton Object -> Edit, select all the text, go to the Home tab on the Ribbon, open the Font dialog box, check the Hidden Effect.
HTH,

MV
Thankyou!