Entering unicode 'accents' via sendkeys

ozaru

New Member
Joined
Apr 8, 2010
Messages
2
I'm trying to use Excel for a Chinese vocabulary list. The Chinese characters aren't the problem at the moment: what I'm trying to solve is the pinyin, i.e. the pronunciation shown in Western alphabetic letters, with accents (diacritics) to show the four tones.

For example, the word for hotel is 'luguan' -- except to be precise, the first 'u' should have two dots above it (like a German umlaut) and above the dots a little 'v' (like an upside-down French circumflex). The way to write this is as 'u' (U+0075) followed by the Combining Diaeresis (U+0308) then the Combining Caron (U+030C). All these diacritical marks can be seen e.g. in Character Mapper by doing 'Group by: Unicode subrange' then selecting 'Combining Diacritical Marks'. Only 4 of them are in fact needed to mark the tones: U+0304 (tone 1: macron), U+0301 (tone 2: acute accent), U+030C (tone 3: caron) and U+0300 (tone 4: grave accent). U+0308 is also needed for the double-dotted 'u', as although the German umlaut could be used instead (U+00FC), it looks awful when combined with other diacritics.

Now, as copying & pasting these marks from character mapper is a real chore, I thought it would be easy to redefine e.g. Control 1/2/3/4 to insert the relevant 'accent' as follows:

Application.OnKey "^1", "SendKeys ChrW(&H304)"
Application.OnKey "^2", "SendKeys ChrW(&H301)"
Application.OnKey "^3", "SendKeys ChrW(&H30C)"
Application.OnKey "^4", "SendKeys ChrW(&H300)"

However, pressing even an ordinary 'u' followed by Ctrl-1 etc. does not seem to work, either in an Excel cell (when inputting the data initially) or inside a dialogue box etc. (when testing myself).

What am I doing wrong?

[Incidentally, there seems to be a strange bug in Excel 2007 in that inserting multiple copies of the 'lu+diaeresis+caron' symbol into a cell results in lots of 'l's followed by a single 'u+diaeresis+caron' (the content is actually intact, but this is how it is displayed: possibly just my display driver?).]
 

ozaru

New Member
Joined
Apr 8, 2010
Messages
2
This has now been solved thanks to the kind people at OzGrid.
The basic problem was that macros do not run in edit mode, and the solution was to use AutoCorrect when inputting into cells, and TextBox_Change when inputting into a dialogue box.
 

Forum statistics

Threads
1,082,250
Messages
5,364,022
Members
400,774
Latest member
Goldi paul

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top