【问题标题】:How to capture the "Print" button from the menu bar in a macro如何从宏的菜单栏中捕获“打印”按钮
【发布时间】:2010-09-14 05:13:29
【问题描述】:

我有一张带有自定义按钮的工作表,我可以通过它控制打印过程。

现在用户点击菜单栏的打印图标,这会产生一个“未定义”的输出。

如何拦截这个菜单栏按钮?

  • 谢谢

【问题讨论】:

    标签: excel printing vba


    【解决方案1】:

    处理 Workbook_BeforePrint 事件。

    private sub Workbook_BeforePrint (cancel as boolean)
      '//g_MyFlag is set when the user clicks you toolbar button.
      '//It must get cleared in the end of your procedure.
      if not g_MyFlag then cancel = true: exit sub
    
    end sub
    

    在 MS Word 中,也可以重新定义系统宏本身。您必须创建一个名为FilePrint() 的宏,Word 会改为自己调用它。可惜你不能在 Excel 中做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多