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"
....
开发者_如何学GoThis 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:
- 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?
- how can I find this number?
- 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.
精彩评论