mercredi 28 juin 2017

Enable export as pdf inside Workbook_BeforePrint Cancel

it seems my "Workbook_BeforePrint(Cancel As Boolean)" is stopping me from exporting to PDF. I have found that if I remove this sub, PDF export works, but I'd like to keep my "fixes" before print.

Is there a way to rewrite my code to handle export to pdf?

A) To ignore the "Before print cancel" on export (no after effects on PDF)

or

B) Make the code work for export, retaining the after effects my code adds

Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Application.Volatile True
    Cancel = True

    Application.EnableEvents = False
    Application.ScreenUpdating = False

   'My code

    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub

Aucun commentaire:

Enregistrer un commentaire