Solved

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

Posted on 2009-04-01
13
7,785 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

762 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