Excel (Office 365) Workbook_BeforePrint event not firing

essdeeay

New Member
Joined
Oct 3, 2013
Messages
4
There have been other similar threads on here, but none have fixed this issue.

I want to insert content into the header of the spreadsheet, and the way to do this (I believe) is to use the Workbook_Before_Print() function:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Debug.Print "Running Workbook_BeforePrint"
    Cancel = True
End Sub

However, it isn't working - nothing is appearing in the Immediate window of the VBA editor. I can confirm that events are enabled because Worksheet_Change() works OK and as expected:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    MsgBox "You just changed " & Target.Address
End Sub


Why does the Workbook_BeforePrint function not work? I don't actually need to get this to work, providing I can populate the header/footer of the sheet before printing.

Many thanks,
Steve
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You're code works for me.
Where is the code located?
Also, did you just do Ctrl P, or did you click print afterwards?
 
Upvote 0
It's located in "Sheet1", but I've just tried it in "ThisWorkbook" and now it works. However, it doesn't work for PrintPreview, only when you actually print. Is there a way to get it in at the preview stage?

Many thanks ;)
 
Upvote 0
[SOLVED] Re: Excel (Office 365) Workbook_BeforePrint event not firing

Thanks for the help Fluff :)

The solution was that Workbook_BeforePrint() only works in the Workbook object.
 
Last edited:
Upvote 0
Re: [SOLVED] Re: Excel (Office 365) Workbook_BeforePrint event not firing

You're welcome
 
Upvote 0
Re: [SOLVED] Re: Excel (Office 365) Workbook_BeforePrint event not firing

The solution was that Workbook_BeforePrint() only works in the Workbook object.
Yep, here is a little tip.
All the procedures that begin with "Workbook" only work in the "ThisWorkbook" module.
All the procedures that begin with "Worksheet" only work in the specific "Sheet" modules.
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,946
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top