Before_Print event

J

Jan Kronsell

--
For den, der kun kender en hammer,
komme alle problemer hurtigt til at ligne søm.
 
J

Jan Kronsell

And this was empty :-(

Anyway

I need som code to change interior colors before print, and reset them
after.

I have tried something like this on the Before_Print Event

Range("A1").Interior.ColorIndex = xlNone
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Range("A1").Interior.ColorIndex = 6

The problem is, that the sheet is printed twice, onece without the
background color, and once with it.

If I add

Cancel = True, nothing is printed at all.

Jan
 
B

Bob Phillips

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
Application.EnableEvents = False
Range("A1").Interior.ColorIndex = xlNone
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Range("A1").Interior.ColorIndex = 6
Cancel = True
Application.EnableEvents = True
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
J

Jan Kronsell

Thank you very much.

Jan

Bob said:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
Application.EnableEvents = False
Range("A1").Interior.ColorIndex = xlNone
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Range("A1").Interior.ColorIndex = 6
Cancel = True
Application.EnableEvents = True
End With
End Sub
 
Top