I was trying to make a button that converts the selected text to traditional Chinese using
private void totradbutton_Click(object sender, RibbonControlEventArgs e)
{
Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;
currentRange.TCSCConverter(Word.WdTCSCConverterDirection.wdTCSCConverterDirectionSCTC,true,true);
}
however when the button is run on some selected text, the text is not changed to traditional Chinese. I have tried it on simplified, traditional, and a mixture and still nothing happens. I have put a message box in to check that the code is run, which it is. The return type of TCSCConverter is void, so it does not return a converted form.
The manual page
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.range.tcscconverter.aspx does not seem to be too enlightening.
There doesn’t seem to be any change to currentRange.text
Please can someone explain my mistake to me.
Although I am unable to determine why it doesn’t work, a work around is to use the
strConvfunction in theMicrosoft.VisualBasicAssembly:This seems to work without problems for already converted text or paragraph breaks, though there may be other problems I have not spotted.