Bizarre slowing down of macro
Posted by Tamsin on August 08, 2001 8:28 AM
Hello everyone,
I have been working on a new reporting application for my company. I'm now just polishing it off, testing, etc. One of the things I wanted to do was for the reports to always come out on one page (the report size changes). I used this sort of code:-
Sub Test()
t = Timer
With sht1
.PageSetup.Zoom = False
.PageSetup.Orientation = xlPortrait
.PageSetup.PrintArea = .UsedRange.Address
.PageSetup.FitToPagesTall = 1
.PageSetup.FitToPagesWide = 1
.Protect
End With
With sht2
.PageSetup.Zoom = False
.PageSetup.Orientation = xlLandscape
.PageSetup.PrintArea = .UsedRange.Address
.PageSetup.FitToPagesTall = 1
.PageSetup.FitToPagesWide = 1
.Protect
End With
MsgBox Timer - t
End Sub
Now when I run this on my (not completely ancient) 500mhz machine it takes around 5 seconds. I'm creating about 20 reports so that's nearly a minute just to set the print area when the rest of the macro runs in about 2 seconds.
Does anyone know why this takes so long and/or how I can get around this?
Thanks in advance,
Tamsin.