Printing-don't need half this code but which half?:-)
Sorry you can comment out the printpreview. I added that in for debugging. I
try not to kill too many trees when I am trying to get the printing to work
out...
--
HTH...
Jim Thomlinson
"Jim Thomlinson" wrote:
If you want to ensure that the printouts are absolutely identical then you
need all of the settings. While it is unlikely that anyone is going to play
with 90% of those settings the only way to ensure 100% it to define all of
the settings. If however all you want to define is the print area then there
is not much to that...
With Sheets("Data1")
.PageSetup.PrintArea = "$A$1:$F$21"
.PrintPreview
.PrintOut
end with
With Sheets("Data2")
.PageSetup.PrintArea = "$A$1:$F$15"
.PrintPreview
.PrintOut
end with
Note that for all of the other settings whatever the user set them to last
is the value that will be used. So if they changed margins or headers or such
then that is what they will get.
--
HTH...
Jim Thomlinson
"TD" wrote:
Hi,
I've recorded a macro for printing pre-selected ranges. The spreadsheet is
going out to lots of users who will all have different ways of setting the
print range - some more successful than others. So I thought I would put a
button in so that everyone would in theory get the same printout.
I'm sure there's lots in here that isn't needed just don't know what.
This is a just part of the whole code (prints 11 sheets with varying areas-
there are 15 sheets in book).
Sheets("Data1").Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = "$A$1:$F$15"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Data2").Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = "$A$1:$F$21"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "Data2"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.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
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 2
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub
I also had a thought that someone here would be able to tell me how to cut
down on some of the code I'm sure I need to do With Selection and Endwith but
not sure where and what so that properties common to all printing is only
coded once.
I'm at the record macro and muddle about stage but learning all the time so
it would be great is someone could work out what I mean and then help.
Many thanks
--
TD
|