Thanks JulieD
Unfortunately I do not have privileges to download add-ins at the office.
However I was able to work out the following code today (an embedded macro),
which works for a single worksheet and am happy to share. The most annoying
part was to figure out the outlined levels (every time you group rows or
columns you create a new outline leve). I did neither know that was the way
the were called or that you could actually create code to change the level
showed.
ActiveSheet.Outline.ShowLevels RowLevels:=(variable from 0 to x),
ColumnLevels:=(variable from 0 to y)
Now I have to work out how to extrapolate it to be able to use it with
multiple worksheets. Any ideas anyone?
Here is the code worked out so far for anyone that may find it useful.
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 20/09/2004 by RojasR
'
'
If Sheet7.Range("dropdownboxcell") = "2" Then
Sheets("Sheetname").Select
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=3
ActiveSheet.ResetAllPageBreaks
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.PageSetup.PrintArea = "$cell$:$cell$"
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
ActiveWindow.View = xlNormalView
With ActiveSheet.PageSetup
.PrintTitleRows = "$row:$row"
.PrintTitleColumns = "$column:$collumn"
.LeftHeader = "&""Arial,Bold""Title"
.CenterHeader = ""
.RightHeader = "&""Arial,Bold""Second Title"
.LeftFooter = "&""Arial,Bold""&Z&F"
.CenterFooter = "&""Arial,Bold""&P"
.RightFooter = "&""Arial,Bold""&D"
.LeftMargin = Application.InchesToPoints(0.354330708661417)
.RightMargin = Application.InchesToPoints(0.354330708661417)
.TopMargin = Application.InchesToPoints(0.590551181102362)
.BottomMargin = Application.InchesToPoints(0.590551181102362)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA3
.FirstPageNumber = xlAutomatic
.Order = xlOverThenDown
.BlackAndWhite = False
.Zoom = 45
.PrintErrors = xlPrintErrorsDisplayed
End With
Application.Dialogs(xlDialogPrint).Show
Else
If Sheet7.Range("dropdownboxcell") = "3" Then
Sheets("Sheetname").Select
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=2
ActiveSheet.ResetAllPageBreaks
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.PageSetup.PrintArea = "$cell$:$cell$"
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
ActiveWindow.View = xlNormalView
With ActiveSheet.PageSetup
.PrintTitleRows = "$row:$row"
.PrintTitleColumns = "$column:$column"
.LeftHeader = "&""Arial,Bold""Title"
.CenterHeader = ""
.RightHeader = "&""Arial,Bold""Second Title"
.LeftFooter = "&""Arial,Bold""&Z&F"
.CenterFooter = "&""Arial,Bold""&P"
.RightFooter = "&""Arial,Bold""&D"
.LeftMargin = Application.InchesToPoints(0.354330708661417)
.RightMargin = Application.InchesToPoints(0.354330708661417)
.TopMargin = Application.InchesToPoints(0.590551181102362)
.BottomMargin = Application.InchesToPoints(0.590551181102362)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlOverThenDown
.BlackAndWhite = False
.Zoom = 48
.PrintErrors = xlPrintErrorsDisplayed
End With
Application.Dialogs(xlDialogPrint).Show
Else
If Sheet7.Range("dropdownboxcell") = "4" Then
Sheets("Sheetname").Select
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1
ActiveSheet.ResetAllPageBreaks
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.PageSetup.PrintArea = "$cell$:$cell$"
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Range("cell").Select
ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
ActiveWindow.View = xlNormalView
With ActiveSheet.PageSetup
.PrintTitleRows = "$row:$row"
.PrintTitleColumns = "$column:$column"
.LeftHeader = "&""Arial,Bold""Title"
.CenterHeader = ""
.RightHeader = "&""Arial,Bold""Second Title"
.LeftFooter = "&""Arial,Bold""&Z&F"
.CenterFooter = "&""Arial,Bold""&P"
.RightFooter = "&""Arial,Bold""&D"
.LeftMargin = Application.InchesToPoints(0.354330708661417)
.RightMargin = Application.InchesToPoints(0.354330708661417)
.TopMargin = Application.InchesToPoints(0.590551181102362)
.BottomMargin = Application.InchesToPoints(0.590551181102362)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlOverThenDown
.BlackAndWhite = False
.Zoom = 49
.PrintErrors = xlPrintErrorsDisplayed
End With
Application.Dialogs(xlDialogPrint).Show
End If
End If
End If
End Sub
Cheers!
redroyx
JulieD said:
Hi
Have you checked out the Report Manager add-in which is designed to do this
for you ... have a look at the following knowledge base article
http://support.microsoft.com/default.aspx?scid=kb;en-us;873209
How to install the Excel 2002 Report Manager add-in in Excel 2003
The report manager allows you to nominate sheets in any order from a
workbook, and for each sheet you can nominate a view (from the insert /
custom view menu) and / or a scenario (if required) and you can also print
consecutive page numbers across the whole lot.
Cheers
JulieD