Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
HELLO VB EXPERTS,
It seems that Workbook_BeforePrint event is triggered by both PrintOut and PrintPreview. Is it possible that I could run a different code for each of the command the user will choose. somewhat like: Private Sub Workbook_BeforePrint If user choose PrintOut Then My code goes here Else My other code goes here End If End Sub Anyone who could give light to my problem will be highly appreciated Thanks in advance, Jon-jon |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could use a more elaborate form but this should get you started. Place
the code in the "ThisWorkbook" module Private Sub Workbook_BeforePrint(Cancel As Boolean) Cancel = True Dim Msg As String, Style As String, Title As String Dim Response As String, MyAnswer As String Msg = "Select 'Yes' to Print, 'No' to Print Preview, 'Cancel' to exit" Style = vbYesNoCancel + vbQuestion Title = "Print or Print Preview" Response = MsgBox(Msg, Style, Title) Application.EnableEvents = False If Response = vbYes Then MyAnswer = "No printing allowed" 'or other code for a macro here ElseIf Response = vbNo Then MyAnswer = "Print Preview allowed" 'or other code for a macro here ActiveSheet.PrintPreview ElseIf Response = vbCancel Then MyAnswer = "Bailing out" End If Application.EnableEvents = True MsgBox MyAnswer End Sub -- XL2002 Regards William "JON-JON" wrote in message ... | HELLO VB EXPERTS, | | It seems that Workbook_BeforePrint event is triggered by both PrintOut and | PrintPreview. Is it possible that I could run a different code for each of | the command the user will choose. somewhat like: | | Private Sub Workbook_BeforePrint | | If user choose PrintOut Then | My code goes here | Else | My other code goes here | End If | | End Sub | | Anyone who could give light to my problem will be highly appreciated | | Thanks in advance, | | Jon-jon | | | | | |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) |