LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default PageSetup Performance Question


PageSetUp can take its own time, however your 16 seconds seems excessive.
Do you have an object reference set to the worksheet?
That might help and it is a good idea anyway.

You can use the actual point settings instead of InchesToPoints.
There are 72 point to the inch, so your left margin, for instance, could be...
..LeftMargin = 18

Make sure you prune all settings you don't need...
..CenterHeader and .CenterFooter can go and others?

Finally, if all else fails, XL4 macro code is faster than VBA with PageSetUp.
See... http://www.mcgimpsey.com/excel/udfs/pagesetup.html
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"bstobart"
wrote in message
I've written a MS-Project VBA macro to export data to MS-Excel. The macro
works fine. The performance is good...until I get to the PageSetup section,
then the performance drops. The entire macro takes 26 seconds to run, but 16
seconds of that are used up on the PageSetup command, which seems strange.

I've included the PageSetup section below. As you can see I've commented
out the portions that are not needed. Any ideas?
----------------------------------

Set ExcelApp = CreateObject("Excel.application") ' Open Excel.
Default is
ExcelApp.visible=false
....
ExcelApp.ScreenUpdating = False
ExcelApp.EnableEvents = False
....
.DisplayPageBreaks = False ' I've read that this line should help but
it didn't

With .PageSetup
.PrintArea = AllDataRange.Address
.PrintTitleRows = "$2:$2"
' .PrintTitleColumns = ""
' .LeftHeader = ""
' .CenterHeader = ""
' .RightHeader = ""
.LeftFooter = "&8&Z&F"
.CenterFooter = "Page &P of &N"
.RightFooter = "Printed: &D &T"
.LeftMargin = ExcelApp.InchesToPoints(0.25)
.RightMargin = ExcelApp.InchesToPoints(0.25)
.TopMargin = ExcelApp.InchesToPoints(0.5)
.BottomMargin = ExcelApp.InchesToPoints(0.5)
.HeaderMargin = ExcelApp.InchesToPoints(0.25)
.FooterMargin = ExcelApp.InchesToPoints(0.25)
' .PrintHeadings = False
' .PrintGridlines = False
' .PrintComments = xlPrintNoComments
' .PrintQuality = 600
' .CenterHorizontally = False
' .CenterVertically = False
.Orientation = xlLandscape
' .Draft = False
.PaperSize = xlPaperLetter
' .FirstPageNumber = xlAutomatic
' .Order = xlDownThenOver
' .BlackAndWhite = False
' .Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
' .PrintErrors = xlPrintErrorsDisplayed
End With ' .PageSetup

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
performance question Gary Keramidas Excel Programming 5 November 13th 07 03:22 PM
Performance question Schizoid Man[_2_] Excel Programming 4 November 24th 06 10:38 AM
performance question Gary Keramidas[_2_] Excel Programming 5 July 16th 05 09:40 PM
PageSetup Simon Shaw[_4_] Excel Programming 1 May 28th 04 08:41 AM
VBA 'PageSetup' performance John[_74_] Excel Programming 1 January 29th 04 01:28 AM


All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"