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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel vba macro, can this be made to run faster? 1

Status
Not open for further replies.

Junior1544

Technical User
Apr 20, 2001
1,267
US
i have a vba macro to print the current sheet... i want to make it run faster, but i don't know if i can have certain things default, and leave them out, or if there is a faster way to do it all together... here is my code if some one can help me make it run faster... Thanks

--James


Sub Print()

On Error GoTo err_Print

ActiveSheet.PageSetup.PrintArea = "$B$2:$H$19"
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 170
End With

ActiveWindow.SelectedSheets.PrintOut Copies:=1
Range("B11").Select

exit_Print:
Exit Sub
err_Print:
MsgBox "Called From: VB_General.Print " & Chr$(10) & Chr$(13) & "Error Description: " & Err.Description & Chr$(10) & Chr$(13) & "Error Code: " & Err.Number, vbCritical
GoTo exit_Print
End Sub JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Try,
Code:
Sub Print()
   On Error GoTo err_Print
    ActiveSheet.PageSetup.PrintArea = "$B$2:$H$19"
    With ActiveSheet.PageSetup
       .PrintArea = "$B$2:$H$19"
       .Zoom = 170
    End With  
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
exit_Print:
  Exit Sub
err_Print:
  MsgBox "Called From: VB_General.Print " & Chr$(10) & Chr$(13) & "Error Description: " & Err.Description & Chr$(10) & Chr$(13) & "Error Code: " & Err.Number, vbCritical
  GoTo exit_Print
End Sub

A.C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top