ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   before print event not working (https://www.excelbanter.com/excel-programming/289402-before-print-event-not-working.html)

goss[_17_]

before print event not working
 
Hi all

Appears my b4 print event is not working.
When I print I receive no right header or center footer
I tried commenting out the .rh and .cf out of the print routine
Received same results

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("Main").Activate
With ActiveSheet.PageSetup
.RightHeader = ActiveSheet.Range("C1").Value
.CenterFooter = ActiveSheet.Range("C2").Value
End With
End Sub

Print Routine:
Sub Print_Main()

Application.ScreenUpdating = False
Worksheets("Main").Select
Range("B4:J47").Select
ActiveSheet.PageSetup.PrintArea = "$B$4:$J$47"
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "&8&D"
.CenterFooter = ""
.RightFooter = "&8&T"
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = True
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("D7").Select
Application.ScreenUpdating = True
End Su

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

before print event not working
 
A very cursory look suggests that perhaps you dont have a period before each
item in your with

--
Don Guillett
SalesAid Software

"goss " wrote in message
...
Hi all

Appears my b4 print event is not working.
When I print I receive no right header or center footer
I tried commenting out the .rh and .cf out of the print routine
Received same results

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("Main").Activate
With ActiveSheet.PageSetup
RightHeader = ActiveSheet.Range("C1").Value
CenterFooter = ActiveSheet.Range("C2").Value
End With
End Sub

Print Routine:
Sub Print_Main()

Application.ScreenUpdating = False
Worksheets("Main").Select
Range("B4:J47").Select
ActiveSheet.PageSetup.PrintArea = "$B$4:$J$47"
With ActiveSheet.PageSetup
PrintTitleRows = ""
PrintTitleColumns = ""
LeftHeader = ""
CenterHeader = ""
RightHeader = ""
LeftFooter = "&8&D"
CenterFooter = ""
RightFooter = "&8&T"
LeftMargin = Application.InchesToPoints(0.75)
RightMargin = Application.InchesToPoints(0.75)
TopMargin = Application.InchesToPoints(1)
BottomMargin = Application.InchesToPoints(1)
HeaderMargin = Application.InchesToPoints(0.5)
FooterMargin = Application.InchesToPoints(0.5)
PrintHeadings = False
PrintGridlines = False
PrintComments = xlPrintNoComments
PrintQuality = 600
CenterHorizontally = False
CenterVertically = False
Orientation = xlPortrait
Draft = False
PaperSize = xlPaperLetter
FirstPageNumber = xlAutomatic
Order = xlDownThenOver
BlackAndWhite = True
Zoom = False
FitToPagesWide = 1
FitToPagesTall = 1
PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("D7").Select
Application.ScreenUpdating = True
End Sub


---
Message posted from
http://www.ExcelForum.com/




goss[_18_]

before print event not working
 
Thanks Don

There is a . before each item within the With statement.
Any other ideas?


---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 03:14 AM.

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