码迷,mamicode.com
首页 > 其他好文 > 详细

简繁转换的VBS代码

时间:2015-09-03 14:02:18      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

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。

简繁转换的VBS代码

标签:

原文地址:http://www.cnblogs.com/system32/p/simplified-tranditional-vbs-code.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!