VB Command Button

L

LW_Greeney

Hiya guys....

I have created a VB Button into my word document which has a macro attached
to it. But when I print the page I dont want to show the button, How can I
change it so the button only sppears in the page and not on the printed
documents?

Alistaire
 
L

LW_Greeney

hi jay,

have have done what it says, but i have more than one button within all the
document, have have 6 pages with buttons on each?
does this work for all buttons?
 
J

Jay Freedman

Do all the buttons do the same thing -- print the entire document? Or do
they have separate functions, like printing the current page? In fact, do
they print at all, or do their macros do something else?
 
L

LW_Greeney

There is only 1 button that prints, then the rest are just buttons to move
about the document! All buttons are macros going to a different bookmark on
the document.

I know in excel there is an option called printobject which you can change
to failse but i cannot find that in word.
 
J

Jay Freedman

There is an option labeled "Drawing objects" on the Print tab of the Tools >
Options dialog that controls whether Word prints the drawing objects in the
document. For this purpose, drawing objects include text boxes as well as
pictures, AutoShapes, and other graphics.

If the text boxes containing the command buttons are the only drawing
objects in the document, you could uncheck that option and print, and none
of the text box/command button objects would be printed.

To do this automatically, open the macro attached to the button that prints,
and put this code between the Sub line and the End Sub line:

' declare a variable
Dim bOptPrintDrawings As Boolean

' save the existing option value
bOptPrintDrawings = Options.PrintDrawingObjects
Options.PrintDrawingObjects = False

' print the document
ActiveDocument.PrintOut Background:=False

' restore the option to original value
Options.PrintDrawingObjects = bOptPrintDrawings

If your document has other drawing objects, then we'll have to do something
more complicated. If that's the case, are these six the only text boxes in
the document?
 
R

Richard

I have jumped into this thread because I have a similar problem. I have only
one command button which does various things. However, the user will print
via the normal means Ctrl P, Print, etc. However, I don't want to print the
command button, but do want to print graphics, text boxes, (JPG's, etc).
 
J

Jay Freedman

Hi Richard,

The solution I'll recommend for you is not the one discussed earlier in this
thread. You should instead look at the article
http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm, which explains
that macros with specific names will execute instead of the built-in
commands. You should give your command button a name, and the
print-intercepting macros can then hide the button or change its color to
white, print the document, and then restore the button's appearance.

Actually, a better solution would be to create a custom button on a toolbar
in your template, instead of a command button in the document body. That
way, you never have to worry about the printing issue. See
http://www.word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Richard

Hi Jay,

Pretty much as I suspected. The first link has helped me out greatly. I did
not know how to do this. Thanks.

Before you replied, I did resort to a macro from a cutom button on the menu
bar. But because the document is being used by work colleagues who will be
less familiar with Word, macros and the document, i was worried that they may
forget to run the macro so instead there is a big command button where it is
needed. Thus I will use your first technique proposed and resort to the less
favoured solution of 'hiding' the command button temporarily. Many thanks.

Regards,

Richard
 

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