在Excel中打印速度更快

编程入门 行业动态 更新时间:2024-10-23 15:19:22
本文介绍了在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

一些更新:

  • 对于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中打印速度更快

    本文发布于:2023-06-01 10:28:49,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/412977.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:更快   打印速度   Excel

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!