M
Montana
PRINT1 WORKS FINE; PRINT2 RETURNS A RUN-TIME 1004 ERROR. EACH SUB REFERS TO A
DIFFERENT WORKSHEET IN A WORKBOOK.
Sub Print1()
'
'
' Print Macro
' Macro written 6/28/2006 by djones
' Copied here 10/12/2006
Worksheets("Summary").Activate
Range("A1:AA22").Select
ActiveSheet.PageSetup.PrintArea = "A1:AA22"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("A:B").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub
Sub Print2()
Worksheets("Assumptions").Activate
Range("A133").Select
ActiveSheet.PageSetup.PrintArea = "A133"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub
DIFFERENT WORKSHEET IN A WORKBOOK.
Sub Print1()
'
'
' Print Macro
' Macro written 6/28/2006 by djones
' Copied here 10/12/2006
Worksheets("Summary").Activate
Range("A1:AA22").Select
ActiveSheet.PageSetup.PrintArea = "A1:AA22"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("A:B").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub
Sub Print2()
Worksheets("Assumptions").Activate
Range("A133").Select
ActiveSheet.PageSetup.PrintArea = "A133"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub