• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Print Settings Macro not working

Betsy Byrne

New Member
Hello,

I recorded a print settings macro that i had used (successfully for years) on a previous machine. It is not working properly; specifically, it will fit all columns on one page, but it is not adding the headers and footers I want...
which are:
Header: FileName (carriage return) SheetName {all in Arial bold 14}
left footer "E.Byrne | FileName&Path"
right footer "Page / Pages"

Code:
Sub PrintFormat()
'
' PrintFormat Macro
'
' Keyboard Shortcut: Ctrl+Shift+P
'
  Application.PrintCommunication = False
  With ActiveSheet.PageSetup
  .PrintTitleRows = "$1:$1"
  .PrintTitleColumns = ""
  End With
  Application.PrintCommunication = True
  ActiveSheet.PageSetup.PrintArea = ""
  Application.PrintCommunication = False
  With ActiveSheet.PageSetup
  .LeftHeader = ""
  .CenterHeader = "&""Arial,Bold""&14&F" & Chr(10) & "&A"
  .RightHeader = ""
  .LeftFooter = "E.Byrne | &Z&F"
  .CenterFooter = ""
  .RightFooter = "&P / &N"
  .LeftMargin = Application.InchesToPoints(0.2)
  .RightMargin = Application.InchesToPoints(0.2)
  .TopMargin = Application.InchesToPoints(0.75)
  .BottomMargin = Application.InchesToPoints(0.75)
  .HeaderMargin = Application.InchesToPoints(0.3)
  .FooterMargin = Application.InchesToPoints(0.3)
  .PrintHeadings = False
  .PrintGridlines = True
  .PrintComments = xlPrintSheetEnd
  .PrintQuality = 1200
  .CenterHorizontally = True
  .CenterVertically = False
  .Orientation = xlLandscape
  .Draft = False
  .PaperSize = xlPaperLetter
  .FirstPageNumber = xlAutomatic
  .Order = xlDownThenOver
  .BlackAndWhite = False
  .Zoom = False
  .FitToPagesWide = 1
  .FitToPagesTall = False
  .PrintErrors = xlPrintErrorsDisplayed
  .OddAndEvenPagesHeaderFooter = False
  .DifferentFirstPageHeaderFooter = False
  .ScaleWithDocHeaderFooter = True
  .AlignMarginsHeaderFooter = True
  .EvenPage.LeftHeader.Text = ""
  .EvenPage.CenterHeader.Text = ""
  .EvenPage.RightHeader.Text = ""
  .EvenPage.LeftFooter.Text = ""
  .EvenPage.CenterFooter.Text = ""
  .EvenPage.RightFooter.Text = ""
  .FirstPage.LeftHeader.Text = ""
  .FirstPage.CenterHeader.Text = ""
  .FirstPage.RightHeader.Text = ""
  .FirstPage.LeftFooter.Text = ""
  .FirstPage.CenterFooter.Text = ""
  .FirstPage.RightFooter.Text = ""
  End With
  Application.PrintCommunication = True
End Sub

Thanks!
~E.Byrne
 
Hi Betsy

You seem to be missing a line of code to do the printing. Give the following a try at the bottom of your file.

Code:
ActiveWindow.SelectedSheets.PrintOut 1, True


Take care

Smallman
 
Thanks Smallman, but I don't want the macro to actually print the document; I only want it to designate my print formatting settings, which it is not doing. It is not adding the header of Filename and SheetName even though that is what has been recorded:
Code:
  .CenterHeader = "&""Arial,Bold""&14&F" & Chr(10) & "&A"
  .RightHeader = ""
  .LeftFooter = "E.Byrne | &Z&F"
  .CenterFooter = ""
  .RightFooter = "&P / &N"
 
Back
Top