H
Howard Kaikow
In Excel 2003, on an old computer, the PageSetUp stuff (code below) takes
6-7 seconds in a visible Excel VBA IDE.
Using VB6 to automate Excel, corresponding code takes 9 seconds.
Commenting out the .Order = xlDownThenOver saves about 1 second.
Commenting out the .FirstPageNumber = xlAutomatic seems to have no impact,
likely because it is the default.
Does not seem to be any way to speed things up.
Sub TestPageSetup()
Dim d As Double
Dim d1 As Double
Application.ScreenUpdating = False
With ActiveSheet
Debug.Print Application.ScreenUpdating
Debug.Print Now
''''''''''''''''''''''''''''''''''''''''
With .PageSetup
.Orientation = xlLandscape
With .Application
d = .InchesToPoints(0.5)
d1 = .InchesToPoints(0.75)
End With
.LeftMargin = d
.RightMargin = d
.TopMargin = d1
.BottomMargin = d1
.HeaderMargin = d
.FooterMargin = d
.LeftHeader = "&F"
.CenterHeader = "&A"
.RightHeader = ""
.LeftFooter = "&D(&T)"
.CenterFooter = ""
.RightFooter = "Page &P of &N"
.PrintGridlines = True
' .FirstPageNumber = xlAutomatic
' .Order = xlDownThenOver
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
''''''''''''''''''''''''''''''''''''''''
Debug.Print Now
End With
Debug.Print Application.ScreenUpdating
Application.ScreenUpdating = True
End Sub
6-7 seconds in a visible Excel VBA IDE.
Using VB6 to automate Excel, corresponding code takes 9 seconds.
Commenting out the .Order = xlDownThenOver saves about 1 second.
Commenting out the .FirstPageNumber = xlAutomatic seems to have no impact,
likely because it is the default.
Does not seem to be any way to speed things up.
Sub TestPageSetup()
Dim d As Double
Dim d1 As Double
Application.ScreenUpdating = False
With ActiveSheet
Debug.Print Application.ScreenUpdating
Debug.Print Now
''''''''''''''''''''''''''''''''''''''''
With .PageSetup
.Orientation = xlLandscape
With .Application
d = .InchesToPoints(0.5)
d1 = .InchesToPoints(0.75)
End With
.LeftMargin = d
.RightMargin = d
.TopMargin = d1
.BottomMargin = d1
.HeaderMargin = d
.FooterMargin = d
.LeftHeader = "&F"
.CenterHeader = "&A"
.RightHeader = ""
.LeftFooter = "&D(&T)"
.CenterFooter = ""
.RightFooter = "Page &P of &N"
.PrintGridlines = True
' .FirstPageNumber = xlAutomatic
' .Order = xlDownThenOver
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
''''''''''''''''''''''''''''''''''''''''
Debug.Print Now
End With
Debug.Print Application.ScreenUpdating
Application.ScreenUpdating = True
End Sub