ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Before_Print event (https://www.excelbanter.com/excel-programming/416225-before_print-event.html)

Jan Kronsell

Before_Print event
 


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



Jan Kronsell

Before_Print event
 
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






Bob Phillips

Before_Print event
 
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)

"Jan Kronsell" wrote in message
...
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








Jan Kronsell

Before_Print event
 
Thank you very much.

Jan

Bob Phillips wrote:
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


"Jan Kronsell" wrote in message
...
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





All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com