Type Tones in MS Office

Type Tones in MS Office using this MS Office Macro
by Mark Linden O’Meara

Want to type in pinyin in Ms-Word? Here’s an easy viable solution! Need to write in Pinyin on a webpage? Just type your pinyin in Word and then copy and paste it into the webpage!

Here’s an example!

Just type the vowel and the tone, then invoke the macro and it will convert.

Examples:

Type Ni2 then press Cntl+] and it gets converted to Ní

Type Ha3 then press Cntl+] and it gets Hǎ then just type the o!

Type u5 or U5 then Cntl+] to get the ü character

To make use of the macro you can use Method A – download a Word file with the macro already installed, or Method B – install the macro yourself.

Method A – Easiest

Click Here to download a Word 2013 document with the Macro (PinyinTonesMacroDocument.docm) and then open the file, enable macros and assign keyboard keys to run your macro.   Or Click Here to download a Word 2003 2007 document with the Macro (PinyinTonesMacroDocument.doc)

The Docm file should already have the macro enabled.

Once you enable the macro you will need to set the keys to invoke it. I recommend using the Control key plus the ] which is above the Enter key. This makes it easy to invoke with little interruption in typing.

In Office 2007 set the macro keyboard shortcut by doing the following:

1) Click on the Office button and select Word Options

2) Click on “Customize”

3) Find the Keyboard Shortcuts near the bottom of the screen. Click on the Customize button.

4) On the Categories area, scroll down and find Macros. Click on Macros to select it.

5) You should see AsYouTypePinyinMacro in the area on the right hand side. Click on AsYouTypePinyinMacro to select it.

6) Click in the Press New Shortcut Keys box. Hold down the control key and press ]

7) The Assign button. The Assigned Keys box should show Ctrl+] Click the close button. You will then be returned to the Customize main dialogue box. Click Ok. You will then be returned to your document.

8) Test your macro by typing Ni2 and then hold down the control key and press ] The ni2 should convert to ní

Method B – Install the Macro Yourself

To Install the Macro

Part 1 – Adding the Macro

1) Open Word, click on the View Tab, Click on the top portion of the Macro button. The dialogue box will open up

2) In the Name field enter (yes, its case sensitive)    AsYouTypePinyinMacro then click on the Create Button.

You should now be in the VBA Macro Editor.

3) In The VBA editing window, replace ALL the code for the AsYouTypePinyinMacro including the heading and all the way to the End Sub command with the code at the end of this document. Make sure you only replace the code in the AsYouTypePinYin section starting with Sub AsYouTypePinyinMacro()  to the next End Sub  command.

4) In the VBA editor, go to the File Menu and choose ‘Close and Return to Microsoft Word’ You should now be back in your word document.

Your macro is now installed. To invoke the macro you need to add it to the toolbar, or set up a shortcut key. Here are the instructions for doing this.

Part 2-  Adding A Keyboard Shortcut

Your macro is installed, but you need to tell MS-Word how and when to run the macro. I have found that setting up ‘Cntl’ and ‘]’ to invoke the macro as a easy to type sequence and as far as I know, with no conflicts with other programs.

To set up MS-Word to convert text to pinyin:

Office 2007

1. Click on the Office button, choose Word Options, then Customize. On the left side of the panel, drop down the list from the “Choose commands from” and select macro.

2. The AsYouTypePinyinMacro should appear in the panel below. Click on Normal.NewMacros.AsYouTypePinYinMacro to select it.

3. Look below the panel to find the Keyboard Shortcuts Customize button and click on it.

4. The Keyboard Shortcuts dialogue box will appear. In the commands list, scroll down and click on Macros. On the right side you should see AsYouTypePinyinMacro and click on it. It should then appear selected.

5. Click in the Keyboard Shortcut box. Hold down the Control Key and then press the ] key. The box should now display Cntl+]

6. Click on the Assign button at the bottom left corner of the dialog box. The Current Keys box should now display Cntl+] Click Close. You should then be returned to the Word Options Menu. Click Close.

Office 2003

1. Click on the Tools Menu and select Customize.

2. Click on Keyboard.

3. Scroll down the left side list and select Macros

4. Select AsYouTypePinyinMacro on the left side list

5. Click In the Keyboard Shortcut box and then hold down the control key then the ] key.

6. Click the Assign button and close the dialogue box.

7. Click OK or Close on the Customize dialogue box.

Test your macro by typing Ni2 and then pressing Cntl+] You should see i2 converted to í Try out other pinyin combinations! Enjoy.

Mark Linden O’Meara

http://www.soulcarepublishing.com

Select all the text starting with Sub AsYouTypePinYin() to the end of this document and then click COPY on the home button

Sub AsYouTypePinyinMacro()

‘ AsYouTypePinyin Macro

‘ (C) 2010 Mark Linden O’Meara

‘ available at http://www.SoulCarePublishing.com

Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend

Select Case Selection

Case “a1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=257, Unicode:=True

Case “a2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=225, Unicode:=True

Case “a3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=462, Unicode:=True

Case “a4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=224, Unicode:=True

Case “e1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=275, Unicode:=True

Case “e2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=233, Unicode:=True

Case “e3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=283, Unicode:=True

Case “e4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=232, Unicode:=True

Case “i1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=299, Unicode:=True

Case “i2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=237, Unicode:=True

Case “i3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=464, Unicode:=True

Case “i4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=236, Unicode:=True

Case “o1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=333, Unicode:=True

Case “o2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=243, Unicode:=True

Case “o3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=466, Unicode:=True

Case “o4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=242, Unicode:=True

Case “u1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=363, Unicode:=True

Case “u2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=250, Unicode:=True

Case “u3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=468, Unicode:=True

Case “u4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=249, Unicode:=True

Case “u5”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=252, Unicode:=True

Case “A1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=256, Unicode:=True

Case “A2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=193, Unicode:=True

Case “A3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=461, Unicode:=True

Case “A4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=192, Unicode:=True

Case “E1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=274, Unicode:=True

Case “E2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=201, Unicode:=True

Case “E3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=282, Unicode:=True

Case “E4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=200, Unicode:=True

Case “I1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=298, Unicode:=True

Case “I2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=205, Unicode:=True

Case “I3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=463, Unicode:=True

Case “I4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=204, Unicode:=True

Case “O1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=332, Unicode:=True

Case “O2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=211, Unicode:=True

Case “O3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=465, Unicode:=True

Case “O4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=210, Unicode:=True

Case “U1”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=362, Unicode:=True

Case “U2”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=218, Unicode:=True

Case “U3”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=467, Unicode:=True

Case “U4”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=217, Unicode:=True

Case “U5”

Selection.InsertSymbol Font:=”+Body”, CharacterNumber:=220, Unicode:=True

Case Else

‘No pinyin code entered

End Select

‘ (c) 2010 Mark Linden O’Meara

‘ Available at http://www.soulcarepublishing.com

End Sub