Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access VBA Formatting Excel .PageSetup Time Consuming Why? 1

Status
Not open for further replies.

TurtleMx

IS-IT--Management
Apr 5, 2012
2
BE
Hello All!

Does somebody knows why it takes more processor time when setting some .PageSetup properties?
See example below:

With .Sheets(sSheet).PageSetup
.LeftHeader = "" 'Time consuming
.CenterHeader = "&A" 'Time consuming
.RightHeader = "" 'Time consuming
.LeftFooter = "&F" 'Time consuming
.CenterFooter = "&D" 'Time consuming
.RightFooter = "Page &P" 'Time consuming
.LeftMargin = xlApp.InchesToPoints(0.25) 'Time consuming
.RightMargin = xlApp.InchesToPoints(0.25) 'Time consuming
.TopMargin = xlApp.InchesToPoints(1) 'Time consuming
.BottomMargin = xlApp.InchesToPoints(1) 'Time consuming
.HeaderMargin = xlApp.InchesToPoints(0.5) 'Time consuming
.FooterMargin = xlApp.InchesToPoints(0.5) 'Time consuming
.PrintArea = "" ' Resets or clears PrintArea 'Fast!
.PrintArea = "A1:L" + CStr(lngLastRow) 'Fast!
.Order = xlOverThenDown 'Time consuming
.PrintHeadings = False 'Time consuming
.PrintGridlines = False 'Time consuming
.PrintQuality = 600 'Time consuming
.CenterHorizontally = True 'Time consuming
.CenterVertically = True 'Time consuming
.Orientation = xlLandscape 'Time consuming
.Draft = False 'Time consuming
.PaperSize = xlPaperA4 'Time consuming
.BlackAndWhite = False 'Time consuming
.Zoom = False 'Fast!
.FitToPagesWide = 1 'Fast!
.FitToPagesTall = 1 'Fast!
.PrintErrors = xlPrintErrorsDisplayed 'Fast!
End With

Any idea to speed it up?

Thank you!
Cheerio/TurtleMx
 

First I would eliminate all lines of code that do not change anything. What I mean is, if by default you already have PrintHeadings set to False, eliminate this line of code. So if you do not want to print Headings, all lines about the Headings may gone, right? That will speed it up.

Also, try to set your default priter to some other printer and try your code again. If that will speed it up, consider updatating your (curently default) printer's driver.

Have fun.

---- Andy
 
Thank you Andy! I'll simplify the code. For the printer, its a network printer on which I don't have any rights. But I'll make a test on a local printer just to see if it go faster.

Cheers/TurtleMx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top