views:

20

answers:

1

Hello All,

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"
....

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

A: 

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.

GSerg
OK I'll try that; and what about the command bar names, do they have similar ID's, because EDIT isn't EDIT in other languages as well
MikeD
ahhhh I see, they do have an ID as well .... hack-hack
MikeD
No, edit IS edit in other languages. Because, unlike the controls, the command bars have `.Name` and `.NameLocal`.
GSerg
final solution based on your proposal is to replace ...Controls("Paste")... by ...FindControl(ID:=22)... for paste and 755 for Paste Special. Will need to add one line for standard tool buttons as well - grrr - many thans for your help GSerg
MikeD