Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default BeforePrint only running once

I have a workbook with a sheet name "Data" (among others) if the "Data" sheet
is selected and the user tries to print then I am running the following Macro:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
MsgBox ("The Print Preview will be viewed first." & Chr(10) & "Click the
close button when finished reviewing.")
If ActiveSheet.Name < "Data" Then
Exit Sub
Else:
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="missy"
Rows("3:3").Select
Selection.EntireRow.Hidden = True
With ActiveSheet
.PrintPreview
Cancel = True
End With
dsa = MsgBox("Continue with Print?", vbYesNo)
If dsa = vbNo Then
Rows("3:3").Select
Selection.EntireRow.Hidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="missy"
Range("a1").Select
Exit Sub
End If
MsgBox ("Select your printer" & Chr(10) & "name and click okay")
Application.Dialogs(xlDialogPrinterSetup).Show
Application.ActiveSheet.PrintOut
Application.EnableEvents = True
Rows("3:3").Select
Selection.EntireRow.Hidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="missy"
Range("a1").Select
End If
End Sub


The problem is: If I select no (at "continue Printing?") and then try to
print again it goes directly to the print dialog box not thrugh the macro.

Have I messed something up???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default BeforePrint only running once

If you select No, you exit the sub without executing

Application.EnableEvents = True

so your subsequent print commands don't fire the BeforePrint event.



In article ,
jasminesy wrote:

The problem is: If I select no (at "continue Printing?") and then try to
print again it goes directly to the print dialog box not thrugh the macro.

Have I messed something up???

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default BeforePrint only running once

When I put the Application.EnableEvents = True before the exit sub also it
worked perfect.

Thank You so much...

"JE McGimpsey" wrote:

If you select No, you exit the sub without executing

Application.EnableEvents = True

so your subsequent print commands don't fire the BeforePrint event.



In article ,
jasminesy wrote:

The problem is: If I select no (at "continue Printing?") and then try to
print again it goes directly to the print dialog box not thrugh the macro.

Have I messed something up???


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
BeforePrint Robin Clay Excel Programming 4 February 13th 07 03:48 PM
BeforePrint help Rookie 1st class Excel Programming 4 November 19th 05 09:57 PM
BeforePrint Add In Daniel McCollick[_2_] Excel Programming 10 June 10th 05 08:07 PM
ADO 2.7 & ADO 2.8 beforeprint JCanyoneer Excel Programming 7 March 30th 05 04:05 PM
Help with BeforePrint Eric[_7_] Excel Programming 2 October 9th 03 07:44 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"