简繁转换的VBS代码

Class TCSCConverter
Private Word, Doc

Private Sub Class_Initialize()
Set Word = CreateObject("Word.Application")
End Sub

Private Sub Class_Terminate()
Word.Quit
Set Word = Nothing
End Sub


'转化成简体
Public Function TC2SC(str)
Set Doc = Word.Documents.Add
Word.Selection.TypeText str
Doc.Range.TCSCConverter 1, True
TC2SC = Replace(Doc.Range.Text, vbCr, vbCrLf)
TC2SC = Left(TC2SC, Len(TC2SC) - 2)
Doc.Saved = True
Doc.Close
Set Doc = Nothing
End Function

'转化成繁体
Public Function SC2TC(str)
Set Doc = Word.Documents.Add
Word.Selection.TypeText str
Doc.Range.TCSCConverter 0, True, True
SC2TC = Replace(Doc.Range.Text, vbCr, vbCrLf)
SC2TC = Left(SC2TC, Len(SC2TC) - 2)
Doc.Saved = True
Doc.Close
Set Doc = Nothing
End Function

End Class

Set TCSC = New TCSCConverter

WScript.Echo TCSC.SC2TC("我下面给你吃")
WScript.Echo TCSC.SC2TC("我干妹妹的故事")

保存为Translate.vbs,编码类型为ASIN。

posted @ 2015-09-03 13:38  system32  阅读(480)  评论(0编辑  收藏  举报