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

Re: Hide Command Button when Printing by Helmut

Helmut
Wed Feb 14 21:07:05 CST 2007

Hi Gail,

>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

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.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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


RE: Hide Command Button when Printing by Gail

Gail
Thu Feb 15 11:06:00 CST 2007

Helmut

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

"Gail" wrote:

> 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
>

Re: Hide Command Button when Printing by Helmut

Helmut
Fri Feb 16 02:52:42 CST 2007

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.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Helmut Weber