Pinyin Zhou logo Pinyin Joe's

Chinese Computing Help Desk

 

Custom Search
 Home / What's New » Downloads » Chinese Pinyin macro for Word and Excel

Pinyin Macro for MS Word and Excel

Automatically convert Pinyin with tone numbers
into Pinyin with tone marks (diacritics)

Hanyu Pinyin tones

Download Macro for Word 1.3: Windows Office 97-2010, Mac Office 98-2004, 2011
(2011: converts your whole document including tables. Size: 2 KB Zip file, 13 KB text file.)

Download Macro for Word 1.2: Windows Office 97-2010, Mac Office 98-2004, 2011
(2010: converts selected text or text before cursor. Size: 1 KB Zip file, 10 KB text file.)

Download Macro for Excel 1.2: Windows Office 97-2010, Mac Office 98-2004, 2011
(2010. Size: 3 KB Zip file, 20 KB text file.)

Not Compatible with Macintosh Office 2008, iWorks, or OpenOffice/LibreOffice
(Conversion of these macros into OOo and/or Libre is planned for the near future)

 

Pinyin Macro Instructions
Overview ... Use These Fonts... Installation... Ruby Text 

Pinyin Macro Help
FAQs & Technical Notes ... Contact Information


Overview

These macros are very simple to use, as easy as "1-2-3":

  1. Type Pinyin with numbers representing the tones. For example, "Han4yu3 Pin1yin1".
  2. In Word, macro version 1.2 will let you select text or place the cursor at the end of text you want to convert. Macro version 1.3 will just convert the whole document, and works better with tables. In Excel, select cells if you wish and the next step will offer you a choice of selected cells, entire worksheets or all worksheets in a workbook.
  3. Invoke the macro by pressing <alt-F8> and double-clicking on the macro name.*

Simple as that!

*In Excel, you can assign a keyboard shorcut to each macro by clicking the Options button you will see there. In Word, you may want to raise this macro to the top of the list by adding "aa" to the front of the name so you can just hit <Enter> instead of double-clicking on the macro name.


Use These Fonts

To use this macro, the only other thing to remember is that you'll need to select one of the following fonts:


Arial
Courier New
Times New Roman
(See note on 2010/2007 Calibri & Cambria below.)

Arial, Courier New, Times New Roman In most recent versions of Office, these "core" fonts have been updated to include at least enough of the Unicode character set to display Pinyin with tone marks.
Arial Unicode MS Arial Unicode The default Unicode font, included since MS Office 2000. Safest for use in Access databases too.
Lucida Sans Unicode Lucida Sans Unicode The default Unicode font in earlier versions of Windows. Also used in Mac systems.

Office 2010 and 2007 include all of these fonts. Their default fonts, Calibri and Cambria, did not include all the necessary characters in Office 2007 until I installed Office Multi-Language Pack 2007 new site but the full character set is now standard in Office 2010's Calibri and Cambria without any Language Pack or other update. (Why is this a problem? Well, in a fresh installation of Office 2007 if you don't have the updated fonts you may not notice this problem at first, but some of the Calibri letters with tones will convert to Arial, or some of the Cambria letters with tones will be Times New Roman, and the final result may be ugly.)

Office XP (2002) and 2003 include the latest Arial, Courier New and Times New Roman, and those editions also normally install the Arial Unicode MS font as the "Universal Font", also known as the "Unicode Font" as part of International Support.

In Office 2000 that font is an option. If you did not install it, for either XP 2002/2003 or 2000, follow the instructions for "Installing the Unicode Font" on Microsoft's "Administering Fonts for Office XP" page.

I'm not sure how to find that font if you're missing it in older versions of Macintosh Office, but I bet Mac users don't even have this kind of problem.

Again, you do not need to worry about missing any of these fonts in Windows Vista or Office 2010, Office 2007, or for most installations of Office XP/2002/2003, so just go ahead and try using the macro first before getting concerned with this.

Installation

Click one of the download links at the top of this page, and copy/extract the file to your PC.

To install, open Word or Excel as appropriate and press <alt-F8> (or on the Mac <Cmd-F8> right? It's been awhile...). Type a name for the macro and hit the "Create" button. Then open the downloaded file, select all the text and copy it into a blank macro. Paste it between the lines already in there, "Sub" and "End Sub", being careful not to erase those!

The Excel macro must have a very specific name, noted on one of the first comment lines in the file. You can call it anything when you first create the blank macro, but then follow the instructions in the comment lines for renaming. If you don't do this, the macro will convert text in selected cells but the versions for worksheets and entire workbooks will not run. Also, if your Excel is set to insert the command "Option Explicit" into a new macro module, make sure you end up with only one instance of that in each module.

If you need further help creating or saving a macro, the Help files in Word and Excel have all the information you need. Just enter "macro" in the Help index and drill down to info on creating a macro "from scratch". Excel can be especially difficult about security: you must enable macros, and in some versions of Excel you must save your final spreadsheet as a macro-enabled file. See also the Troubleshooting section of the Pinyin macro FAQ page.

If you get ambitious, the Help files in Visual Basic editor (launched when you click the "Edit" button in the macro dialog within Word or Excel) can help you add tweaks of your own. For example, you can tell the Word macro to search forward from your cursor instead of backwards by setting "Forward=" to "True".

Ruby Text

Although you can use this macro to create "ruby" text (small phonetic transcriptions aligned above or alongside Chinese characters), there is an easier way: there are inexpensive Chinese character fonts available that include Pinyin ruby text, and there is MS Word's Phonetic Guide. With either of these options you'll have to input the Chinese characters first of course. See this section of my Zhuyin setup page for more information: Zhuyin and Pinyin ruby fonts and Microsoft Word's Phonetic Guide. I also briefuly mention the Phonetic Guide in OpenOffice (in my Ubuntu Linux section, but there is also a version of OpenOffice for Windows).

Need More Help?

There is a Troubleshooting section on the macro FAQ page. I've tested these macros in the Windows versions of Office 2010, Office 2007 (but see my note about the default Calibri and Calabria fonts), Office 2003, Office XP/2002 and Office 97, and I tried it out on Macintosh Office 2004 right there at Apple headquarters. I am told they will work in Macintosh Office 98 through 2004, and maybe even the mid-nineties version 4.2, but Mac Office 2008 is not compatible with this type of macro. I hope to get these VBA macros converted to AppleScript soon, and also modified for OpenOffice.org. Please send questions, comments or suggestions anytime via the contact page.

« top


Home / What's New Frequently Asked Questions About Pinyin About Pinyin Joe Contact Pinyin Joe
Windows 7 Chinese Windows Vista Chinese Windows XP Chinese Ubuntu Linux Chinese Other OS: Mac, phones
Free Downloads Pinyin Macro for Word/Excel Pinyin Macro FAQ Chinese Calendar-Outlook Asia Wallpaper
More Chinese Fonts Apps: Chinese IMs and tools   Encoding Standards Site Map

Copyright © 2005 PinyinJoe.com.  All Rights Reserved.   Page copy protected against web site content infringement by Copyscape
"Microsoft", "Windows", "Linux", "Ubuntu", "Apple", "Macintosh" and any other trademarks on this site are the sole property of their respective owners.