View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Howard Kaikow Howard Kaikow is offline
external usenet poster
 
Posts: 269
Default PageSetup is very slow

Using the code below, one can see that the slow parts ar the settting of the
margins and
the settings of the Headers/Footers.

(5/17/2008 03:51:02) Start PageSetup
(5/17/2008 03:51:02) Start Orientation
(5/17/2008 03:51:03) Start Margins
(5/17/2008 03:51:06) Start HeaderFooter
(5/17/2008 03:51:09) Start Gridlines
(5/17/2008 03:51:10) Start ZoomFit
(5/17/2008 03:51:10) End PageSetup


LogMessage "Start PageSetup"
With .PageSetup
LogMessage "Start Orientation"
.Orientation = xlLandscape
LogMessage "Start Margins"
.LeftMargin = HeaderFooterLeftRightMargin
.RightMargin = HeaderFooterLeftRightMargin
.TopMargin = BottomTopMargin
.BottomMargin = BottomTopMargin
.HeaderMargin = HeaderFooterLeftRightMargin
.FooterMargin = HeaderFooterLeftRightMargin
LogMessage "Start HeaderFooter"
.LeftHeader = "&F"
.CenterHeader = "&A"
.RightHeader = ""
.LeftFooter = "&D(&T)"
.CenterFooter = ""
.RightFooter = "Page &P of &N"
LogMessage "Start Gridlines"
.PrintGridlines = True
' .FirstPageNumber = xlAutomatic
' .Order = xlDownThenOver
LogMessage "Start ZoomFit"
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
LogMessage "End PageSetup"

Since the program will be creating N +3 worksheets, I can push the overhead
to the Form's Load event by
setting the properties in the Sheet1 created by Excel when creating a New
Workbook, and then,
instead of adding a worksheet, as needed, I can COPY Sheet1.