macros for print

H

hitesh

i read somwere in Dicsussion Group Post.
If Cell A1 Contain "Print", then Document should Print.If A1 is blank print
will not work.

pls help.
 
G

Gord Dibben

In Thisworkbook module.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveWorkbook.Sheets("Sheet1").Range("A1") <> "Print" Then
MsgBox "Cannot print"
Cancel = True
End If
End Sub


Gord Dibben MS Excel MVP
 
×

מיכ×ל (מיקי) ×בידן

Try the Workbook_BeforePrint Event-Macro:
================================================
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If UCase(Sheets(1).[A1]) <> "PRINT" Then
Cancel = True
Else
Cancel = False
End If
End Sub
=========
Micky
 
H

hitesh

its not working, iam using excel 2007

Gord Dibben said:
In Thisworkbook module.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveWorkbook.Sheets("Sheet1").Range("A1") <> "Print" Then
MsgBox "Cannot print"
Cancel = True
End If
End Sub


Gord Dibben MS Excel MVP



.
 
H

hitesh

after pasting a code in THIS WORKBOOK Module, i try to run the macros, but
there is no macros.
what to do


מיכ×ל (מיקי) ×בידן said:
Try the Workbook_BeforePrint Event-Macro:
================================================
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If UCase(Sheets(1).[A1]) <> "PRINT" Then
Cancel = True
Else
Cancel = False
End If
End Sub
=========
Micky


hitesh said:
i read somwere in Dicsussion Group Post.
If Cell A1 Contain "Print", then Document should Print.If A1 is blank print
will not work.

pls help.
 
G

Gord Dibben

This is not a macro you "run".

It is event code which is triggered by you selecting the Print Icon or
File>Print.


Gord
 

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

Top