开发者

Excel CommandBars / Controls in local languages

Win-XP / Excel 2003 / VBA ....

I have the following piece of code to intercept all paste activities initiated by the user (main menu, context menu and control-V key) and send it to a Sub TrappedPaste()

....
Application.CommandBars("Edit").Controls("Paste").OnAction = "TrappedPaste"
Application.CommandBars("Edit").Controls("Paste Special...").OnAction = "TrappedPaste"
Application.CommandBars("Cell").Controls("Paste").OnAction = "TrappedPaste"
Application.CommandBars("Cell").Controls("Paste Special...").OnAction = "TrappedPaste"
Application.OnKey "^v", "TrappedPaste"
....
开发者_如何学Go

This code works fine. The miracle happened during worldwide rollout of the sheet, because "Edit" isn't "Edit" and "Paste" isn't "Paste" in German, French and all other languages between (A)leut and (Z)apotec :-O

Q:

  1. Is there a way of achieving independence from the language of the Excel User Interface, i.e. is there a numeric aequivalent to the "Paste" argument which is the same in all national languages?
  2. how can I find this number?
  3. is ctrl-V always ctrl-v in all local Windows languages?

Thanks in advance for any help

Kind regards MikeD


Each control on a toolbar has an ID which can be used with the FindControl function:

? application.CommandBars("Edit").FindControl(msoControlButton, 22).Caption

where 22 is the ID of the Paste button. As far as I was able to check, this number is the same accross different languages.
So you can look them up in the English version and just hardcode them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜