通过JS调用VBA实现简体和繁体的互换的步骤

通过JS调用VBA实现简体和繁体的互换的步骤

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=zh-cn"><script type="text/javascript">
<!--
function j2f() {
var wApp = new ActiveXObject("Word.Application")
var wDoc = wApp.Documents.Add()
wApp.visible = "False"
var username = new String()
txt = document.all.txt1.value
wApp.Selection.TypeText(txt)//将文本框内容写入WORD中
wApp.WordBasic.ToolsSCTCTranslate(0,0,0)//转换成繁体
wDoc.Active
var start = wDoc.Paragraphs(1).Range.Start//所有文本的起点
var end = wDoc.Paragraphs(wDoc.Paragraphs.Count).Range.End -1//所有文本的终点(段落结束多一个字符)
document.all.txt2.value = wDoc.Range(start,end).text//起点->终点内的所有文本内容
wApp.ActiveWindow.Close(0)//不保存就关闭,0为不保存
wApp.Quit()//关闭ActiveXObject对象
}
function f2j() {
var wApp = new ActiveXObject("Word.Application")
var wDoc = wApp.Documents.Add()
wApp.visible = "False"
var username = new String()
txt = document.all.txt2.value
wApp.Selection.TypeText(txt)
wApp.WordBasic.ToolsTCSCTranslate(0,0,0)//转换成简体
wDoc.Active
var start = wDoc.Paragraphs(1).Range.Start
var end = wDoc.Paragraphs(wDoc.Paragraphs.Count).Range.End - 1
document.all.txt1.value = wDoc.Range(start,end).text
wApp.ActiveWindow.Close(0)
wApp.Quit()
}
//-->
</script>

<META content="MSHTML 6.00.2900.2995" name=GENERATOR></HEAD>
<BODY>

<table>
<tr><td>简体</td><td>繁体</td></tr>
<tr><td><TEXTAREA style="HEIGHT: 449px" cols=50 name="txt1"></TEXTAREA></td>
<td><TEXTAREA style="HEIGHT: 449px" cols=50 name="txt2"></TEXTAREA></td><tr><td>
<input type="button" value="简体==>繁体" onclick="j2f()" name="btn1"></td>
<td><input type="button" value="繁体==>简体" onclick="f2j()" name="btn2"></td></tr>
</table></BODY></HTML>