ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pop Up Message before printing (https://www.excelbanter.com/excel-programming/415260-pop-up-message-before-printing.html)

John Web

Pop Up Message before printing
 
I have the following code that prints out different sheets.
What code should I use that will make a message pop up
asking "Are you Sure you want to Print Yes/No" to prevent someone pressing
the print button in error?

Thanks in advance of any favourable reply.

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").Range("newused") = 1
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
If Sheets("Customer Profile").Range("pxselect") 0 Then
Sheets("Handback").PrintOut Copies:=1, Collate:=True
Sheets("New").Range("cuscopynew") = "CUSTOMER COPY"
Sheets("New").PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
End If
Application.ScreenUpdating = True
End Sub

Lars Uffmann

Pop Up Message before printing
 
John Web wrote:
I have the following code that prints out different sheets.
What code should I use that will make a message pop up
asking "Are you Sure you want to Print Yes/No" to prevent someone pressing
the print button in error?


If (MsgBox ("Are you sure you want to print?", vbYesNo) = vbYes) Then
' print
End If



Best Regards,

Lars

Mike H

Pop Up Message before printing
 
Hi,

Mahe these the first 2 lines of your code

response = MsgBox("Do you really want to print?", vbOKCancel)
If response = vbCancel Then Exit Sub

Mike

"John Web" wrote:

I have the following code that prints out different sheets.
What code should I use that will make a message pop up
asking "Are you Sure you want to Print Yes/No" to prevent someone pressing
the print button in error?

Thanks in advance of any favourable reply.

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").Range("newused") = 1
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
If Sheets("Customer Profile").Range("pxselect") 0 Then
Sheets("Handback").PrintOut Copies:=1, Collate:=True
Sheets("New").Range("cuscopynew") = "CUSTOMER COPY"
Sheets("New").PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
End If
Application.ScreenUpdating = True
End Sub


Office_Novice

Pop Up Message before printing
 

Private Sub CommandButton2_Click()
Dim Msg, Style, Title, Response
Msg = "Do you want to print?"
Style = vbYesNo + vbQuestion
Title = "Print"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Application.ScreenUpdating = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").Range("newused") = 1
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
If Sheets("Customer Profile").Range("pxselect") 0 Then
Sheets("Handback").PrintOut Copies:=1, Collate:=True
Sheets("New").Range("cuscopynew") = "CUSTOMER COPY"
Sheets("New").PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
End If
Application.ScreenUpdating = True
Else
End If
End Sub

"John Web" wrote:

I have the following code that prints out different sheets.
What code should I use that will make a message pop up
asking "Are you Sure you want to Print Yes/No" to prevent someone pressing
the print button in error?

Thanks in advance of any favourable reply.

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").Range("newused") = 1
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
If Sheets("Customer Profile").Range("pxselect") 0 Then
Sheets("Handback").PrintOut Copies:=1, Collate:=True
Sheets("New").Range("cuscopynew") = "CUSTOMER COPY"
Sheets("New").PrintOut Copies:=1, Collate:=True
Sheets("Dan").PrintOut Copies:=1, Collate:=True
Sheets("Customer Profile").PrintOut Copies:=1, Collate:=True
End If
Application.ScreenUpdating = True
End Sub



All times are GMT +1. The time now is 03:57 AM.

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