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

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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.
 
Upvote 0

Forum statistics

Threads
1,214,586
Messages
6,120,402
Members
448,958
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top