加入參考 Microsoft Word 12.0 Object Library
命名空間 using Microsoft.Office.Interop.Word;
-
public string TC2SC( string strSource)
-
{
-
string strResult;
-
_Application objWord = new Microsoft. Office. Interop. Word. Application ( );
-
object t = Missing.Value;
-
object nt = Missing.Value;
-
object dt = Missing.Value;
-
object v = true;
-
Document objDocument = objWord.Documents.Add ( ref t, ref nt, ref dt, ref v);
-
objWord.Selection.TypeText (strSource);
-
objWord.Selection.Range.TCSCConverter (WdTCSCConverterDirection.wdTCSCConverterDirectionTCSC, true, true );
-
objWord.ActiveDocument.Select ( );
-
strResult = objWord.Selection.Text;
-
object sc = 0;
-
object of = Missing.Value;
-
object rd = Missing.Value;
-
objWord.Quit ( ref sc, ref of, ref rd);
-
objDocument = null;
-
objWord = null;
-
return strResult;
-
}
-
public string SC2TC( string strSource)
-
{
-
string strResult;
-
_Application objWord = new Microsoft. Office. Interop. Word. Application ( );
-
object t = Missing.Value;
-
object nt = Missing.Value;
-
object dt = Missing.Value;
-
object v = true;
-
Document objDocument = objWord.Documents.Add ( ref t, ref nt, ref dt, ref v);
-
objWord.Selection.TypeText (strSource);
-
objWord.Selection.Range.TCSCConverter (WdTCSCConverterDirection.wdTCSCConverterDirectionSCTC, true, true );
-
objWord.ActiveDocument.Select ( );
-
strResult = objWord.Selection.Text;
-
object sc = 0;
-
object of = Missing.Value;
-
object rd = Missing.Value;
-
objWord.Quit ( ref sc, ref of, ref rd);
-
objDocument = null;
-
objWord = null;
-
return strResult;
-
}
|