I came across a VBA macro that does it in Microsoft Word, at pinyinjoe.com
Had a minor flaw which I reported and he responded that he would incorporate my suggestion "as soon as I can" That was early in January 2014; I haven’t had any motivation to check, since it is already done in my copy.