Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA 'PageSetup' performance

I have a macro that creates some worksheets, then goes through them and sets
Page properties (landscape, margins...) like this:

With ActiveSheet.PageSetup
.Columns.AutoFit
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
...etc..
End With

Performance is TERRIBLE when these statements run. The rest of my macro
only a couple of seconds to complete, but the statements maniuplating the
properties for the PageSetup object run incredibly slow. What makes it
worse, I need to perform the maniuplations on each of the worksheets I
create, exponentially making the problem worse.

Is there another way to do this? Anyone know why its so darned slow? Any
ideas greatly appreciated.

J


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default VBA 'PageSetup' performance

John,

Setting PageSetUp is slow, memory intensive and seems to be the worst in XL97.
The best advice is don't use it unless you have to.
It you must use it, batch all of the settings and only access PageSetUp once per
sheet.
Set DisplayPageBreaks to false before and after calling PageSetUp
Do not reference any settings unless you are changing them.
Reviewing the help file will show you that "Columns" is NOT a property of
PageSetUp.
Make the above changes and see how it works.

An alternative is to set PageSetUp on only one sheet and use that sheet as the
template for your other sheets.

Another alternative, if you are still having problems with performance is to
write the
PageSetUp code in the XL4 macro language.
It does run a little faster that way.
John Green posted a very helpful example of XL4 PageSetUp code a while back.
However, it still took me quite some time to figure it all out and get it to do
what I wanted.

Regards,

Jim Cone
San Francisco, CA

"John" wrote in message
...
I have a macro that creates some worksheets, then goes through them and sets
Page properties (landscape, margins...) like this:


With ActiveSheet.PageSetup
.Columns.AutoFit
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
...etc..
End With


Performance is TERRIBLE when these statements run. The rest of my macro
only a couple of seconds to complete, but the statements maniuplating the
properties for the PageSetup object run incredibly slow. What makes it
worse, I need to perform the maniuplations on each of the worksheets I
create, exponentially making the problem worse.
Is there another way to do this? Anyone know why its so darned slow? Any
ideas greatly appreciated.
J




Reply
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
PageSetup Macro Julian Glass Excel Worksheet Functions 1 March 29th 08 01:54 PM
PageSetup Stanley Excel Discussion (Misc queries) 1 December 14th 05 07:21 PM
SetZoom in PageSetup Bob L[_4_] Excel Programming 0 January 16th 04 04:11 AM
PageSetup is slow Christof DB Excel Programming 4 December 5th 03 04:09 PM
PageSetup slow Oliver Chiu Excel Programming 1 July 10th 03 02:06 PM


All times are GMT +1. The time now is 06:46 PM.

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"