ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_BeforePrint Stopped Working (https://www.excelbanter.com/excel-programming/443489-workbook_beforeprint-stopped-working.html)

O.B.

Workbook_BeforePrint Stopped Working
 
I have the following routine associated with “ThisWorkbook” in my
Visual Basic editor for Excel. It worked fine until I closed
the .xlsm file and reopened it. Now, it doesn’t even execute when
printing. How do I enable it again?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim commonHeader As String

ActiveSheet.PageSetup.CenterHeader = "UNCLASSIFIED"
ActiveSheet.PageSetup.LeftHeader = "GeoBridge SRS"
ActiveSheet.PageSetup.RightHeader = Sheets("Cover").Range("$A$6")
& " - " & _

Format(Sheets("Cover").Range("$A$5"), "DD MMMM YYYY")
ActiveSheet.PageSetup.CenterFooter = "UNCLASSIFIED"

' Exceptions
Sheets("Cover").PageSetup.CenterHeader = "UNCLASSIFIED"
Sheets("Functional Requirements").PageSetup.RightFooter = "Page "
& "&P" & vbCr & "UNCLASSIFIED"

End Sub


Dave Peterson[_2_]

Workbook_BeforePrint Stopped Working
 
Did you remember to allow macros to run when you opened the workbook and saw the
prompt?



On 08/11/2010 13:49, O.B. wrote:
I have the following routine associated with “ThisWorkbook” in my
Visual Basic editor for Excel. It worked fine until I closed
the .xlsm file and reopened it. Now, it doesn’t even execute when
printing. How do I enable it again?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim commonHeader As String

ActiveSheet.PageSetup.CenterHeader = "UNCLASSIFIED"
ActiveSheet.PageSetup.LeftHeader = "GeoBridge SRS"
ActiveSheet.PageSetup.RightHeader = Sheets("Cover").Range("$A$6")
& " - "& _

Format(Sheets("Cover").Range("$A$5"), "DD MMMM YYYY")
ActiveSheet.PageSetup.CenterFooter = "UNCLASSIFIED"

' Exceptions
Sheets("Cover").PageSetup.CenterHeader = "UNCLASSIFIED"
Sheets("Functional Requirements").PageSetup.RightFooter = "Page "
& "&P"& vbCr& "UNCLASSIFIED"

End Sub


--
Dave Peterson


All times are GMT +1. The time now is 01:14 PM.

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