Solved

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

Posted on 2009-04-01
13
8,057 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

 
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

Suggested Solutions

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

738 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