macros for print

  • Thread starter Thread starter hitesh
  • Start date Start date
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.
 
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
 
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



.
 
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.
 
This is not a macro you "run".

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


Gord
 
Back
Top