Solved

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

Posted on 2009-04-01
13
7,229 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:Michael Vasilevsky
  • 6
  • 5
  • 2
13 Comments
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 24044860
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

0
 
LVL 14

Expert Comment

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

0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 24052925
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.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 24053097
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.


0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 24053199
It did print the button...
0
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 24053560
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
0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 24053689
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?
0
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 24054820
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
0
 
LVL 10

Accepted Solution

by:
Michael Vasilevsky earned 0 total points
ID: 24055106
Here's the answer I was looking for (from http://msdn.microsoft.com/en-us/library/aa140269(office.10).aspx): "Select it while in Design Mode and apply "hidden" font formatting. Make sure the option to print hidden text is disabled (click Print on the Options submenu of the Tools menu). (Note that you will probably still see it in Print Preview, but it should not print.)"

Thx anyway.

MV
0
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 24055378
That was too simple. Thanks, I learnt something.
0
 

Expert Comment

by:scarysc
ID: 34264104
dragging up an old thread but how do I apply "hidden"? to the cmd button?
0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 34268316
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
0
 

Expert Comment

by:scarysc
ID: 34287590
Thankyou!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question