after print

  • Thread starter Thread starter inungh
  • Start date Start date
I

inungh

I need set some controls invisible before print which works.

I need set them back visible after print, but after print event does
not exist.
I tried to put in the on activate and on change.

It seems on change event triggle too many times and on activate does
not triggle the codes when print finish.

Are there any workaround to have some code after print?

Your help is great appreciated,
 
Do you hide the controls in the workbook_beforeprint event or do you have a
dedicated macro for printing?

I like the idea of the dedicated macro, then I can control everything I want.

I'd turn off printing in the workbook_beforeprint event:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
msgbox "Print via the dedicated macro"
cancel = true
End Sub

And in my dedicated macro, I'd...

hide the stuff
application.enableevents = false 'so that the before_print event doesn't run
print the other stuff
application.enableevents = true
unhide the stuff

=======
If you don't like that, you could use this technique:


You can use application.ontime to call another routine after a little bit.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
'your routine
'to hide the controls
Application.OnTime Now + TimeSerial(0, 0, 3), "AfterPrint"
End Sub

And in a general module:
Option Explicit
Sub AfterPrint()
'your routine to show the controls
End Sub

Chip Pearson explains application.ontime at:
http://www.cpearson.com/excel/OnTime.aspx

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)
 
Do you hide the controls in the workbook_beforeprint event or do you havea
dedicated macro for printing?

I like the idea of the dedicated macro, then I can control everything I want.  

I'd turn off printing in the workbook_beforeprint event:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    msgbox "Print via the dedicated macro"
    cancel = true
End Sub

And in my dedicated macro, I'd...

hide the stuff
application.enableevents = false 'so that the before_print event doesn't run
print the other stuff
application.enableevents = true
unhide the stuff

=======
If you don't like that, you could use this technique:

You can use application.ontime to call another routine after a little bit..

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    'your routine
    'to hide the controls    
    Application.OnTime Now + TimeSerial(0, 0, 3), "AfterPrint"
End Sub

And in a general module:
Option Explicit
Sub AfterPrint()
    'your routine to show the controls
End Sub

Chip Pearson explains application.ontime at:http://www.cpearson.com/excel/OnTime.aspx

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Thanks millions for helping
 
Back
Top