转自lance的:http://hi.baidu.com/lancy/blog/item/71b2b17e7151b63e0dd7da1e.html


本方法运用Microsoft.Office.Interop.Word.dll所制作,采用word的转换方式,所以转换后会得到繁体的台湾词汇组成的文字,如

getstr("网络打印机打印数据") 会返回

"網路印表機列印資料"

使用时不要忘了添加对Microsoft.Office.Interop.Word.dll的引用

 

 asInput)
    {
        Object template = Type.Missing;
        Object newTemplate 
= Type.Missing;
        Object documentType 
= Type.Missing;
        Object visible 
= Type.Missing;
        Microsoft.Office.Interop.Word.Application aWord 
= null;
        Document doc 
= null;
        Object saveChanges 
= Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
        Object originalFormat 
= Type.Missing;
        Object routeDocument 
= Type.Missing;

        
string sAsInputtemp = asInput;
        
try
        {
            aWord 
= new Microsoft.Office.Interop.Word.Application();
            doc 
= aWord.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
            aWord.Selection.TypeText(asInput);
            
//繁体文字转换成为简体文字,逐词转换
            aWord.Selection.Range.TCSCConverter(WdTCSCConverterDirection.wdTCSCConverterDirectionSCTC, truetrue);
            aWord.ActiveDocument.Select();
            sAsInputtemp 
= aWord.Selection.Text;
        }
        
catch (COMException ex)
        { 
            
throw ex; 
        }
        
finally
        {
            doc.Close(
ref saveChanges, ref originalFormat, ref routeDocument);
            aWord.Quit(
ref saveChanges, ref originalFormat, ref routeDocument);
        }
        
return sAsInputtemp;
    }

相关文章:

  • 2021-11-23
  • 2021-10-11
  • 2021-10-13
  • 2021-08-27
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
  • 2021-09-17
  • 2021-09-27
  • 2021-09-27
相关资源
相似解决方案