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.
 
Ad

Advertisements

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.
 
Ad

Advertisements

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
 
Ad

Advertisements


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

Similar Threads

Print macro 6
Print Macro 1
Print Macro 1
Macro printing 3
Print Macro 7
Print macro 1
Macros for printing 0
Printing Macro 6

Top