Before_Print event

  • Thread starter Thread starter Jan Kronsell
  • Start date Start date
J

Jan Kronsell

--
For den, der kun kender en hammer,
komme alle problemer hurtigt til at ligne søm.
 
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
 
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)
 
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
 

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

Back
Top