#1   Report Post  
NICK
 
Posts: n/a
Default Print Macro

Hello

I would like to write a macro, for a particular workbook, which is activated
when you select File/Print/OK (the macro will check to see if certain
conditions are met and will print if they are but will return an error
message if they are not). Can anyone suggest the code required?

Thanks in advance
Nick
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

There's a workbook event that you can tie into.

Rightclick on the excel icon (to the left of the File option on the worksheet
menu bar).

Select view code and paste this in the code window:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If LCase(Me.Worksheets("sheet1").Range("a1").Value) < "oktoprint" Then
MsgBox "Can't print"
Cancel = True
Else
'do nothing, ok to print
End If
End Sub

You can add any checks you want inside this procedure.



NICK wrote:

Hello

I would like to write a macro, for a particular workbook, which is activated
when you select File/Print/OK (the macro will check to see if certain
conditions are met and will print if they are but will return an error
message if they are not). Can anyone suggest the code required?

Thanks in advance
Nick


--

Dave Peterson
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
Print all charts in a workbook (multiple worksheets) aewsaws Charts and Charting in Excel 4 May 12th 23 03:45 AM
How do i print out my spreadsheet with macro buttons? Chris.... Excel Discussion (Misc queries) 1 December 12th 04 07:29 PM
Non-Breaking Space + Print Issue Barb Reinhardt Charts and Charting in Excel 3 December 9th 04 01:03 AM
Macro for changing print settings Bill Excel Discussion (Misc queries) 3 December 3rd 04 10:49 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


All times are GMT +1. The time now is 07:06 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"