Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Everyone
I used the Macro Recorder to setup a quick-print. Fairly straight-forward requirement. 1. Set the range of the sheet that has data. 2. Set the PrintArea (Including Orientation & Margins defined) 3. Insert Centre Header (including the Date as formatted) 4. Print Preview Sub PrintHDC() Dim SS As Worksheet Dim Rng As Range Dim myDate As Date Set SS = Sheets("HDC") Set Rng = SS.Range("A1:L" & Rows.Count) ' Select only the the range that has data as it will vary everyday myDate = Format(D, "Ddd, dd-Mmm-yy") ' to be included in the Page Header With ActiveSheet.PageSetup .PrintTitleRows = "$1:$1" .PrintTitleColumns = "" End With ActiveSheet.PageSetup.PrintArea= (" ") ' This is the bit where it hangs as I don't know what to insert here to define the variable print area With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "&16HDC - &myDate" ' And this is the other problem, how to incorporate the "Page Header Title" &" - "& myDate as it does not auto-recognise it from the Dim Statement as it says its a (Type Mis-Match) .RightHeader = "" .LeftFooter = "" .CenterFooter = "" .RightFooter = "" .LeftMargin = Application.InchesToPoints(0.33) .RightMargin = Application.InchesToPoints(0.12) .TopMargin = Application.InchesToPoints(0.49) .BottomMargin = Application.InchesToPoints(0.21) .HeaderMargin = Application.InchesToPoints(0.16) .FooterMargin = Application.InchesToPoints(0.12) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .CenterHorizontally = False .CenterVertically = False .Orientation = xlLandscape .Draft = False .PaperSize = xlPaperA4 .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = 100 .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 ActiveWindow.SelectedSheets.PrintPreview End Sub TIA Mick |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
printing setup issue in 2007 | Excel Discussion (Misc queries) | |||
Printing - Setup | Setting up and Configuration of Excel | |||
Page Setup Printing | Excel Discussion (Misc queries) | |||
can VBA be used to set page setup for printing? | Excel Discussion (Misc queries) | |||
setup for userform printing | Excel Programming |