To hide a command button so it doesn't print out

M

Marco

Hello,
I created a command button to automatically update my table of contents in
my word document using the following code:
Private Sub CommandButton1_Click()
ActiveDocument.TablesOfContents(1).Update
End Sub

The button is placed at the end of the document. When I go to print the
final document the button also prints out so I have an "update TOC" button in
my final printed document.
Is there a command button property that makes it so the button doesn't print
out when you print the document?
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Marco > écrivait :
In this message said:
Hello,
I created a command button to automatically update my table of contents in
my word document using the following code:
Private Sub CommandButton1_Click()
ActiveDocument.TablesOfContents(1).Update
End Sub

The button is placed at the end of the document. When I go to print the
final document the button also prints out so I have an "update TOC" button in
my final printed document.
Is there a command button property that makes it so the button doesn't print
out when you print the document?

If all your button does is what you posted, why don't you tell your users to
right-click the ToC and select Update fields in the contextual menu? Much
less trouble!
But if you cannot do that, the easiest would be to put a button on a
toolbar, not in the document itself.
Is your document based on a template other than Normal.dot?

Or, put your button in a paragraph as an inline shape (no wrapping) and
assign a bookmark to that range of text (Insert > Bookmarks...),
"ButtonBookMark" in the example below.
Then you need to intercept the print events with macros called FilePrint
(File > Print or CTRL-P) and FilePrintDefault (The Standard toolbar button).
Do not change the Sub names:

'_______________________________________
Sub FilePrint()

DoThisInstead False

End Sub
'_______________________________________
'_______________________________________
Sub FilePrintDefault()

DoThisInstead True

End Sub
'_______________________________________
'_______________________________________
Sub DoThisInstead(PrintAll As Boolean)

ActiveDocument.Bookmarks("ButtonBookMark").Range.Delete

If Not PrintAll Then
Dialogs(wdDialogFilePrint).Show
Else
ActiveDocument.PrintOut
End If

ActiveDocument.Undo

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
M

Marco

This seems overly complicated to accomplish a simple task.
I've created buttons in excel and made them not print by going to the
properties window and changing the PrintObject but there is no PrintObject
property in the button when I do it in word.

Any thoughts?
Marco
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Marco > écrivait :
In this message said:
This seems overly complicated to accomplish a simple task.
I've created buttons in excel and made them not print by going to the
properties window and changing the PrintObject but there is no PrintObject
property in the button when I do it in word.

Sorry that you do not like the message...
Word is Word and Excel is Excel.

Don't ask me why... I do not know why the people who designed the ActiveX
library for Word did things differently. CommandButtons in Word do not have
a visible property or a PrintProperty.

In my previous post, I gave you 3 alternatives to choose from...
Sorry, no more ideas.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

Howard Kaikow

Marco said:
Hello,
I created a command button to automatically update my table of contents in
my word document using the following code:
Private Sub CommandButton1_Click()
ActiveDocument.TablesOfContents(1).Update
End Sub

The button is placed at the end of the document. When I go to print the
final document the button also prints out so I have an "update TOC" button in
my final printed document.
Is there a command button property that makes it so the button doesn't print
out when you print the document?

Actually, the proper solution is to not include the button in the document,
rather use a toolbar button, or menu item, or keyboard shortcut to run the
very same macro.
 
V

VHII

I am very curious about the solution for this. I am having the same problem.
The template I use has 2 buttons an auto e-mail and a print button. I would
also like them to go away. I can use the print button on the toolbar but the
e-mail button is coded button.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top