Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Hide Command Button when Printing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gail - 14 Feb 2007 19:29 GMT
I have a command button that dletes extra rows in a Word table. When the user
prints the table, I do not want the command button to show. I have tried code
from "how to hide a "Print" button when user clicks on it" in MVP - the
problem is - I do not want to print the document immediatly. I just want the
button hidden when the user choses to print the document. I also tried to
interecpt the Print command and then hide - but it prints 2 copies - one
hidden and one with the button showing. Here is the code I am using to
intercept:
 
Dialogs(wdDialogFilePrint).Show

With ActiveDocument
.Shapes(1).Visible = msoFalse
.PrintOut Background:=False
.Shapes(1).Visible = msoTrue
Helmut Weber - 15 Feb 2007 03:07 GMT
Hi Gail,

>Here is the code I am using to intercept:
>  
[quoted text clipped - 4 lines]
>.PrintOut Background:=False
>.Shapes(1).Visible = msoTrue

which doesn't intercept fileprint a all.

I tried this and that and can only offer
a silly workaround, as
shapes(1).visible = msofalse
doesn't do anything.

Sub FilePrint()
' ActiveDocument.Shapes(1).Visible = msoFalse ?
ActiveDocument.Shapes(1).Delete
' on error resume next
Dialogs(wdDialogFilePrint).Show
' ActiveDocument.Shapes(1).Visible = msoTrue ?
ActiveDocument.Undo 1
End Sub

Note, this assumes, that there is a shape(1)!
But shouldn't be too difficult,
to add a bit more of error handling.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Helmut Weber - 16 Feb 2007 08:52 GMT
Hi,

as deleting it was the last editing action
undo 1
undoes deleting it here and now.

there maybe unwanted sideeffects as with
all workarounds.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Helmut Weber

Gail - 15 Feb 2007 17:06 GMT
Helmut

This macro works great - is there a way to make the command button/shape
reappear after printing as well? Thank you!!

> I have a command button that dletes extra rows in a Word table. When the user
> prints the table, I do not want the command button to show. I have tried code
[quoted text clipped - 11 lines]
> .PrintOut Background:=False
> .Shapes(1).Visible = msoTrue
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.