I work in a centre for people with disabilities and we have a problem
with students pressing the print button many multiples of times when
they go to do a print.

I did post a message a while back asking for any VBA that might be
able to limit printing, the only suggestion I got was to replace the
print button with the print dialog. This didn't really work and only
slowed it down a bit :)

I've been doing a bit of a search and come up with the following:


Public Sub FilePrint()

With Dialogs(wdDialogFilePrint)
If .Display = -1 Then
If .NumCopies > 1 Then
MsgBox "You cannot print more than 1 copy."
Else
.Execute
End If
End If
End With

End Sub


Unfortunately this only allows limiting of the number of copies :(

What I really need is some way of making the print button only work
once in say, 30 seconds or so...... enough time for the students to
see that something is coming out of the printer.

Is there any way in VBA that I could put a timer of sorts on the print
button ?

Cheers,

Re: Limiting the Print Button by Helmut

Helmut
Sun Jun 04 04:33:30 CDT 2006

Hi,

as you've posted in the beginners group, too,
this is beyond a beginner's skills, IMHO.

If you get it to work and understand all,
you're not a beginner anymore.

May not be perfect, meant just to illustrate the principle.

Override the print button.
Check, whether a docvariable "StopPrint" exists.
If not, create it and set it to false.
If it is false, allow printing.
After printing, set "StopPrint" to true.
Start AllowPrinting after 10 seconds.

HTH

Sub FilePrintDefault()
Dim sTmp As String
Dim oDlg As Dialog
Dim rDlg As Long
On Error Resume Next
With ActiveDocument.Variables("StopPrint")
sTmp = .Value
If Err.Number = 5825 Then
.Value = False
On Error GoTo 0
End If
If .Value = False Then
Set oDlg = Dialogs(wdDialogFilePrint)
rDlg = oDlg.Show
If rDlg = 0 Then Exit Sub
.Value = True
Application.OnTime _
When:=Now + TimeValue("00:00:10"), _
Name:="AllowPrint"
Else
MsgBox "Wait til " & _
Format(Now + TimeValue("00:00:10"), "hh:mm:ss")
Exit Sub
End If
End With
End Sub

Sub AllowPrint()
ActiveDocument.Variables("StopPrint") = False
End Sub


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Re: Limiting the Print Button by macropod

macropod
Sun Jun 04 07:07:11 CDT 2006

Hi Drufazz,

To prevent reprinting within a specified timeframe, you could test the
document's internal PRINTDATE value, which is accurate to the minute at
least (it may have higher internal resolution, but minute-level is all you
get via a PRINTDATE field). If you compare that date & time against the
current date & time, via your FilePrint sub, you can at least prevent
reprinting until the next minute ticks over - giving anywhere from 0-60
seconds enforced delay.

Alternatively, you could add the print date & time to the document's custom
properties, with accuracy to the second, and test that before allowing
printing to proceed after whatever interval you choose.

Cheers

--
macropod
[MVP - Microsoft Word]


"Drufazz" <gjf_fazza@hotmail.com> wrote in message
news:osr48213v8lkacbvj5o7pttukso2p31mjm@4ax.com...
> I work in a centre for people with disabilities and we have a problem
> with students pressing the print button many multiples of times when
> they go to do a print.
>
> I did post a message a while back asking for any VBA that might be
> able to limit printing, the only suggestion I got was to replace the
> print button with the print dialog. This didn't really work and only
> slowed it down a bit :)
>
> I've been doing a bit of a search and come up with the following:
>
>
> Public Sub FilePrint()
>
> With Dialogs(wdDialogFilePrint)
> If .Display = -1 Then
> If .NumCopies > 1 Then
> MsgBox "You cannot print more than 1 copy."
> Else
> .Execute
> End If
> End If
> End With
>
> End Sub
>
>
> Unfortunately this only allows limiting of the number of copies :(
>
> What I really need is some way of making the print button only work
> once in say, 30 seconds or so...... enough time for the students to
> see that something is coming out of the printer.
>
> Is there any way in VBA that I could put a timer of sorts on the print
> button ?
>
> Cheers,
>
>
>



Re: Limiting the Print Button by Drufazz

Drufazz
Mon Jun 05 03:56:53 CDT 2006

On Sun, 04 Jun 2006 11:33:30 +0200, Helmut Weber
<nbhymsjxdgcn@mailinator.com> wrote:

>Override the print button.
>Check, whether a docvariable "StopPrint" exists.
>If not, create it and set it to false.
>If it is false, allow printing.
>After printing, set "StopPrint" to true.
>Start AllowPrinting after 10 seconds.

Thanks Helmut, and all who replied. It works great ! :)

I'm not a total beginner, but far from expert :)

Was just wondering, is there any way to get it working without
bringing up the print dialog ?

It looks to me like it's monitoring the print dialog window ?

Can it be made so that it will work when you just press the print
button ?

Many thanks,


>Sub FilePrintDefault()
>Dim sTmp As String
>Dim oDlg As Dialog
>Dim rDlg As Long
>On Error Resume Next
>With ActiveDocument.Variables("StopPrint")
> sTmp = .Value
> If Err.Number = 5825 Then
> .Value = False
> On Error GoTo 0
> End If
> If .Value = False Then
> Set oDlg = Dialogs(wdDialogFilePrint)
> rDlg = oDlg.Show
> If rDlg = 0 Then Exit Sub
> .Value = True
> Application.OnTime _
> When:=Now + TimeValue("00:00:10"), _
> Name:="AllowPrint"
> Else
> MsgBox "Wait til " & _
> Format(Now + TimeValue("00:00:10"), "hh:mm:ss")
> Exit Sub
> End If
>End With
>End Sub
>
>Sub AllowPrint()
> ActiveDocument.Variables("StopPrint") = False
>End Sub


Re: Limiting the Print Button by Helmut

Helmut
Mon Jun 05 04:26:12 CDT 2006

Hi Drufazz,

>Was just wondering, is there any way to get it working without
>bringing up the print dialog ?
>
>It looks to me like it's monitoring the print dialog window ?
>
>Can it be made so that it will work when you just press the print
>button ?

hmm...

On Error Resume Next
With ActiveDocument.Variables("StopPrint")
sTmp = .Value
If Err.Number = 5825 Then
.Value = False
On Error GoTo 0
End If
If .Value = False Then
ActiveDocument.PrintOut ' some possibilities here
.Value = True
Application.OnTime _
When:=Now + TimeValue("00:00:10"), _
Name:="AllowPrint"
Else
MsgBox "Wait til " & Format(Now + TimeValue("00:00:10"),
"hh:mm:ss")
Exit Sub
End If
End With

But, in this case, if the user decides not to print,
printing will be disabled nevertheless for the time span defined.

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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






Re: Limiting the Print Button by Drufazz

Drufazz
Thu Jun 08 04:14:34 CDT 2006

On Mon, 05 Jun 2006 11:26:12 +0200, Helmut Weber
<nbhymsjxdgcn@mailinator.com> wrote:

>>Can it be made so that it will work when you just press the print
>>button ?
>
>hmm...
>
>On Error Resume Next
>With ActiveDocument.Variables("StopPrint")

This works brilliantly Helmut, thanks so much. The problem with "20
copy printouts" is no more :)

Unfortunately we still have this problem with Internet Explorer. Wish
I could install these macros into IE :)

Cheers,