문제

Excel (VBA 사용)의 인쇄 기능은 매우 느립니다. 나는 누군가가 인쇄 속도를 높이는 방법을 갖기를 바라고있다 (Excel 4 매크로 트릭을 사용하지 않고). 내가 지금하는 방법은 다음과 같습니다.

Application.ScreenUpdating = False

With ActiveSheet.PageSetup

  -various setup statements which I've already minimized-

End With   
ActiveSheet.PrintOut

Application.ScreenUpdating = True
도움이 되었습니까?

해결책

예, PageSetup 속성을 설정하면 매우 느립니다.

당신은 이미 설정했습니다 Application.ScreenUpdating = False,이 경우에 똑같이 (또는 그 이상) 중요한 단계는 설정하는 것입니다. Application.Calculation = xlCalculationManual. (이 설정을 저장 한 다음 끝에 원본으로 복원하는 것이 가장 좋습니다.)

또한, 부동산은 각 PageSetup 속성에 대한 속성이 매우 빠르지 만 속성 세트는 너무 느립니다. 따라서 불필요한 (그리고 비싼) 호출을 방지하기 위해 기존 속성 값과 이미 동일하지 않도록 새 속성 설정을 테스트해야합니다.

이 모든 것을 염두에두고 다음과 같은 것처럼 보이는 코드를 사용할 수 있어야합니다.

Dim origScreenUpdating As Boolean
origScreenUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False

Dim origCalcMode As xlCalculation
origCalcMode =  Application.Calculation
Application.Calculation = xlCalculationManual

With ActiveSheet.PageSetup
    If .PrintHeadings <> False Then .PrintHeadings = False
    If .PrintGridlines <> False Then .PrintGridlines = False
    If .PrintComments <> xlPrintNoComments Then .PrintComments = xlPrintNoComments
    ' Etc...
End With

Application.ScreenUpdating = origScreenUpdating
Application.Calculation = origCalcMode

편집 : 몇 가지 업데이트 :

  1. Excel 2010 이상은 'Application.printCommunication'속성을 사용하고 Excel 2007 이하의 경우 'Executexcel4Macro'를 사용할 수 있습니다. 자세한 내용은 참조하십시오 Excel 4 매크로를 VBA로 마이그레이션합니다.

  2. Excel 2007 이하의 경우 또 다른 흥미로운 요령은 프린터 드라이버를 'Microsoft XPS 문서 작성자'에 임시로 할당 한 다음 다시 설정하는 것입니다. 인쇄 속도는 3 배 증가 할 수 있습니다. 보다: 느린 Excel PageSetup 메소드.

도움이 되었기를 바랍니다...

다른 팁

Michael의 게시물을 발전시키고 @RHC의 질문에 대한 답변에서 다음 코드는 단일 워크 시트에서 통합 문서의 여러 워크 시트로 페이지 설정 사용자 정의를 복사 해야하는 경우에도 도움이 될 수 있습니다.

Public Sub CopyPageSetupToAll(ByRef SourceSheet As Worksheet)
    ' Raise error if invalid source sheet is passed to procedure
    '
    If (SourceSheet Is Nothing) Then
        Err.Raise _
            Number:=vbErrorObjectVariableNotSet, _
            Source:="CopyPageSetupToAll", _
            Description:="Unable to copy Page Setup settings: " _
                 & "invalid reference to source sheet."
        Exit Sub
    End If

    SourceSheet.Activate

    With SourceSheet.PageSetup
        ' ...
        ' place PageSetup customizations here
        ' ...
    End With

    SourceSheet.Parent.Worksheets.Select
    Application.SendKeys "{ENTER}", True
    Application.Dialogs(xlDialogPageSetup).Show
End Sub

또는 페이지 설정 변경을 호스팅하기위한 임시 워크 시트를 작성하는 절차를 수정 한 다음 해당 변경 사항을 통합 문서의 다른 워크 시트로 전파 할 수도 있습니다.

Public Sub CopyPageSetupToAll(ByRef SourceBook As Workbook)
    Dim tempSheet As Worksheet

    ' Raise error if invalid workbook is passed to procedure
    '
    If (SourceBook Is Nothing) Then
        Err.Raise _
            Number:=vbErrorObjectVariableNotSet, _
            Source:="CopyPageSetupToAll", _
            Description:="Unable to copy Page Setup settings: " _
                 & "invalid reference to source workbook."
        Exit Sub
    End If

    Set tempSheet = SourceBook.Worksheets.Add

    tempSheet.Activate

    With tempSheet.PageSetup
        ' ...
        ' place PageSetup customizations here
        ' ...
    End With

    SourceBook.Worksheets.Select
    Application.SendKeys "{ENTER}", True
    Application.Dialogs(xlDialogPageSetup).Show
    tempSheet.Delete

    Set tempSheet = Nothing
End Sub

사용으로 인해 SendKeys() 기능 및 Application.Dialogs 기능,이 코드는 가능한 가장 깨끗한 솔루션을 제공하지 않습니다. 그러나 작업이 완료됩니다. :)

통합 문서의 모든 탭에 대해 기본적으로 동일한 페이지 설정을 원한다면 하나의 워크샵을 설정 한 다음 해당 워크 시트의 설정을 다른 워크 시트에 복사하여 속도를 높일 수 있습니까? 이게 가능해?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top