Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Preventing printing

Sorry for the cross posting, but I had posted this to the wrong forum

I want to prevent ptinting of my workbook without using the macro I
have set up for printing. I entered the code below to prevent
printing, but it also prevents my macro from printing. Any ideas how
I
can get around this, or it an all or nothing kind of thing? Also
below
is my print macro.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
msg = MsgBox("Sorry, printing is disabled for this workbook.",
vbCritical)
Cancel = True
End Sub


Private Sub CommandButton2_Click()


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.SortSunday


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.UnSort_AllDays


Unload UserFormPrinting_Sunday


End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Preventing printing

Maybe you could rephrase your posting so someone who has no idea what your
code looks like can understand what you mean. I think you mean that you have
put a before print subroutine in your macro to prevent manual print commands
from the menu bar. But because it runs when your code print command fires,
you cannot execute the print from your code. Is that it?

" wrote:

Sorry for the cross posting, but I had posted this to the wrong forum

I want to prevent ptinting of my workbook without using the macro I
have set up for printing. I entered the code below to prevent
printing, but it also prevents my macro from printing. Any ideas how
I
can get around this, or it an all or nothing kind of thing? Also
below
is my print macro.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
msg = MsgBox("Sorry, printing is disabled for this workbook.",
vbCritical)
Cancel = True
End Sub


Private Sub CommandButton2_Click()


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.SortSunday


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.UnSort_AllDays


Unload UserFormPrinting_Sunday


End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Preventing printing

Try setting you Cancel = False and see if that cures the problem.

" wrote:

Sorry for the cross posting, but I had posted this to the wrong forum

I want to prevent ptinting of my workbook without using the macro I
have set up for printing. I entered the code below to prevent
printing, but it also prevents my macro from printing. Any ideas how
I
can get around this, or it an all or nothing kind of thing? Also
below
is my print macro.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
msg = MsgBox("Sorry, printing is disabled for this workbook.",
vbCritical)
Cancel = True
End Sub


Private Sub CommandButton2_Click()


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.SortSunday


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.UnSort_AllDays


Unload UserFormPrinting_Sunday


End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Preventing printing

By disabling events in CommandButton2 you will avoid generating the before
print event. Try this...

Private Sub CommandButton2_Click()
on error goto ErrorHandler
application.enableevents = false
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Module2.SortSunday
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Module2.UnSort_AllDays
Unload UserFormPrinting_Sunday

ErrorHandler:
application.enableevents = true
End Sub

--
HTH...

Jim Thomlinson


" wrote:

Sorry for the cross posting, but I had posted this to the wrong forum

I want to prevent ptinting of my workbook without using the macro I
have set up for printing. I entered the code below to prevent
printing, but it also prevents my macro from printing. Any ideas how
I
can get around this, or it an all or nothing kind of thing? Also
below
is my print macro.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
msg = MsgBox("Sorry, printing is disabled for this workbook.",
vbCritical)
Cancel = True
End Sub


Private Sub CommandButton2_Click()


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.SortSunday


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


Module2.UnSort_AllDays


Unload UserFormPrinting_Sunday


End Sub



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
preventing the color in a highlighted cell from printing Sally M Excel Discussion (Misc queries) 2 December 17th 07 01:39 PM
Preventing printing [email protected] Excel Worksheet Functions 1 November 24th 07 03:37 PM
preventing printing in Excel misscrf Excel Discussion (Misc queries) 3 January 3rd 07 08:15 PM
can I ensure a drop down list is used i.e by preventing printing Have a Go Excel Discussion (Misc queries) 1 December 15th 06 04:27 AM
Preventing cell contents from printing Blair Scanlan Excel Discussion (Misc queries) 5 December 20th 04 12:39 AM


All times are GMT +1. The time now is 02:04 AM.

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

About Us

"It's about Microsoft Excel"