在Excel中打印速度更快 [英] Printing faster in Excel

查看:87
本文介绍了在Excel中打印速度更快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Excel的打印功能(使用VBA)非常慢.我希望有人可以加快打印速度(无需使用Excel 4 Macro技巧).这是我现在的操作方式:

The print functionality of Excel (using VBA) is extremely slow. I'm hoping someone has a way of speeding the printing up (without using the Excel 4 Macro trick). Here's how I do it now:

Application.ScreenUpdating = False

With ActiveSheet.PageSetup

  -various setup statements which I've already minimized-

End With   
ActiveSheet.PrintOut

Application.ScreenUpdating = True

推荐答案

是的,设置它们的PageSetup属性非常慢.

Yes, the PageSetup properties are very slow when you set them.

您已经设置了Application.ScreenUpdating = False,这很好,但是在这种情况下,同等(或更重要)的重要步骤是设置Application.Calculation = xlCalculationManual. (最好保存这些设置,然后最后将它们还原为原始设置.)

You have already set Application.ScreenUpdating = False, which is good, but an equally (or more) important step in this case is to set Application.Calculation = xlCalculationManual. (It is best if you save these settings and then restore them to the original at the end.)

此外,每个PageSetup属性的属性获取都非常快,而只有属性集是如此之慢.因此,您应该测试新的属性设置,以确保它与现有的属性值不相同,以防止不必要的(且昂贵的)调用.

Additionally, the property get for each PageSetup property is very fast, while it is only the property set that is so slow. Therefore, you should test the new property setting to make sure it isn't already the same as the existing property value in order to prevent an unnecessary (and expensive) call.

牢记所有这些,您应该能够使用类似于以下内容的代码:

With all this in mind, you should be able to use code that looks something like the following:

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及更低版本,则可以使用'ExecuteExcel4Macro'.有关更多详细信息,请参见将Excel 4宏迁移到VBA .

对于Excel 2007及更低版本,另一个有趣的技巧是将打印机驱动程序临时分配给"Microsoft XPS Document Writer",然后将其重新设置.打印速度可以提高3倍.请参阅:缓慢的Excel页面设置方法.

For Excel 2007 and below, another interesting trick is to temporarily assign the printer driver to the 'Microsoft XPS Document Writer' and then set it back. Printing speed can improve by 3x. See: Slow Excel PageSetup Methods.

希望这对您有帮助...

Hope this helps...

这篇关于在Excel中打印速度更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆