I am trying to assemble a macro to bring up a dialog to choose your printer, then print a specific named range with specific properties. I started with a small test statement that works fine.
Sub test()
' test Macro
Application.Dialogs(xlDialogPrinterSetup).Show
ActiveSheet.PageSetup.PrintArea = "Print_20_Year"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
End Sub
Then I moved into the bigger guns and I am not able to get it to work properly. I included the MsgBox
in the macro to see if any of the items were triggering.
No errors, no MsgBox
popup. Any thoughts?
EDIT This is my new and current code. It works fine, buuut as soon as I uncomment the printrowtiles, it breaks. This is code it gives directly from recording a macro.
Sub Print_20_Year()
'
' Print_20_Year Macro
'
'
'
' Range("Print_20_Year").Select
MsgBox "Step .4"
Application.Dialogs(xlDialogPrinterSetup).Show
MsgBox "Step .6"
Application.PrintCommunication = False
MsgBox "Step .7"
' With ActiveSheet.PageSetup
' .PrintTitleRows = "$4:$13"
MsgBox "Step .8"
' .PrintTitleColumns = ""
' End With
MsgBox "Step .9"
Application.PrintCommunication = True
MsgBox "Step 1"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperTabloid
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = False
.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
MsgBox "Step 2"
ActiveSheet.PageSetup.PrintArea = "Print_20_Year"
MsgBox "Step 3"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
End Sub