PageSetup (before XL2010) is notoriously slow due to the communication between VBA and the printer drivers. You should either try to format the sheets ahead of time (e.g. use a template sheet) or use the old XLM PAGE.SETUP method:
Public Sub PageSetupXL4M(Optional LeftHead As String, Optional CenterHead As String, Optional RightHead As String, _
Optional LeftFoot As String, Optional CenterFoot As String, Optional RightFoot As String, _
Optional LeftMarginInches As String, Optional RightMarginInches As String, Optional TopMarginInches As String, _
Optional BottomMarginInches As String, Optional HeaderMarginInches As String, Optional FooterMarginInches As String, _
Optional PrintHeadings As String, Optional PrintGridlines As String, Optional PrintComments As String, _
Optional PrintQuality As String, Optional CenterHorizontally As String, Optional CenterVertically As String, _
Optional Orientation As String, Optional Draft As String, Optional PaperSize As String, _
Optional FirstPageNumber As String, Optional Order As String, Optional BlackAndWhite As String, _
Optional Zoom As String)
'based on a post by John Green in
'microsoft.public.excel.programming
'on 21 January 2001:
'http://google.com/groups?selm=VA.00000b2f.0028c7e5%40mara9"
Const c As String = ","
Dim pgSetup As String
Dim head As String
Dim foot As String
If LeftHead <> "" Then head = "&L" & LeftHead
If CenterHead <> "" Then head = head & "&C" & CenterHead
If RightHead <> "" Then head = head & "&R" & RightHead
If Not head = "" Then head = """" & head & """"
If LeftFoot <> "" Then foot = "&L" & LeftFoot
If CenterFoot <> "" Then foot = foot & "&C" & CenterFoot
If RightFoot <> "" Then foot = foot & "&R" & RightFoot
If Not foot = "" Then foot = """" & foot & """"
pgSetup = "PAGE.SETUP(" & head & c & foot & c & _
LeftMarginInches & c & RightMarginInches & c & _
TopMarginInches & c & BottomMarginInches & c & _
PrintHeadings & c & PrintGridlines & c & _
CenterHorizontally & c & CenterVertically & c & _
Orientation & c & PaperSize & c & Zoom & c & _
FirstPageNumber & c & Order & c & BlackAndWhite & c & _
PrintQuality & c & HeaderMarginInches & c & _
FooterMarginInches & c & PrintComments & c & Draft & ")"
Application.ExecuteExcel4Macro pgSetup
End Sub
Note that you need to activate each sheet when using this.
Bookmarks