ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not a 2nd print from the preview (https://www.excelbanter.com/excel-programming/401078-not-2nd-print-preview.html)

Robert[_36_]

Not a 2nd print from the preview
 
Hello,

The following VBA macro captures the BeforePrint event so thet it prints
only the area I defined. The macro presents a PrintPreview to the user, but
in this Preview window there is another Print button which allows the user
to run a second print. I need to forbid that. How can I deactivate this
Print button in the Preview window ?
Thanks for your help,

Robert
---------------------------------------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Dim Clic As Integer
Application.ScreenUpdating = False
ActiveWorkbook.Protect Structu=False, Password:="XXX"
With Worksheets("DTimpr")
.Activate
.Visible = True
.PageSetup.PrintArea = "DTfinale"
MsgBox "Click on the CLOSE button to close the preview to print out"
.PrintPreview
Clic = MsgBox("After this previw, do you want to print?", vbYesNo,
"Printing of the DT")
If Clic = vbYes Then
.PrintOut Copies:=1, Collate:=True
End If
.Visible = xlVeryHidden
End With
Worksheets("DTForm").Activate
ActiveWorkbook.Protect Structu=True, Password:="XXX"
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub


End Sub




All times are GMT +1. The time now is 11:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com