VBA捕捉到“计算表(shift + f9)".和“计算工作簿"大事记 [英] VBA catch the "calculate sheet (shift+f9)" and "calculate workbook" events

查看:81
本文介绍了VBA捕捉到“计算表(shift + f9)".和“计算工作簿"大事记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这样做是微不足道的还是真的很笨拙:是否可以在VBA中捕获计算表(shift + f9)"和计算工作簿"事件?

I don't know if this is trivial or actually hacky to do : is it possible to catch the "calculate sheet (shift+f9)" and "calculate workbook" events in VBA ?

我想隐藏一些操纵几千行的进程,只显示一些键值.我正在计算一个分布,数千条线,并且只想输出百分位数和一些统计数据,以及图形而不是所有这些线.此刻,我想到的是经典的宏按钮,但我的用户更喜欢F9的生活方式.

I want to hide some processes that manipulate a few thousands lines, to just display some key values. I am calculating a distribution, the thousands lines, and want to just output the percentiles and some stats, as well as the graph instead of all these lines. At the moment I was thinking of a classic macro button, but my users are keener on the F9 way of life..

您是否认为标题中的建议指向了一些有趣的东西?

Do you think I'm pointing towards something interesting with what I suggest in the title ?

推荐答案

OnKey命令允许您禁用任何键或组合键,或使该键执行其他操作.

The OnKey command allows you to disable any key or key combination or make that key do something different.

打开包含宏的工作簿时,将自动执行该宏.

This macro will be executed automatically when the workbook containing it is opened.

Sub Auto_Open()

  Application.OnKey "{F9}", "HandleF9"
  Application.OnKey "^{F9}", "HandleCtrlF9"
  Application.OnKey "+{F9}", "HandleShiftF9"

End Sub

将执行以下例程,而不是执行计算.

The following routines will be executed instead of Calculate.

Sub HandleF9()
  Debug.Print "F9 clicked"
End Sub
Sub HandleCtrlF9()
  Debug.Print "Ctrl+F9 clicked"
End Sub
Sub HandleShiftF9()
  Debug.Print "Shift+F9 clicked"
End Sub

有关更多信息,请参见OnKey帮助.

See OnKey help for more information.

这篇关于VBA捕捉到“计算表(shift + f9)".和“计算工作簿"大事记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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