Pop Up Message before printing

  • Thread starter Thread starter John Web
  • Start date Start date
J

John Web

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
 
John said:
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Command Button 6
print 2 sheets on one paper 5
macro to print a sheet if a cell is a certain value 1
Print Code 7
Printing Macro 4
Assigned macro in Dialog giving error 9
Print Code Help 5
Help with IF 3

Back
Top