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?).]
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,096,357
Messages
5,449,965
Members
405,580
Latest member
MRJT

This Week's Hot Topics

Top