[转]
<SCRIPT LANGUAGE="JavaScript">
<!--
var FileSource;
var FileDesource;
var word;
var xmlhttp;
var filename;
function Load(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
filename = fso.GetSpecialFolder(2) + "\\" + "WjTemp.doc";
//alert(filename);
//OpenWeb();
}catch(e){alert(e.message);};
}
function UnLoad(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filename);
f.Delete();
}catch(e){ShowErrorMsg();};
}
function OpenWeb(){
try{
FileSource = document.WebForm.FileSource.value + "&ID=" + document.WebForm.ID.value + "&FileMode=" + document.WebForm.FileMode.value + "&FileType=" + document.WebForm.FileType.value;
//alert(FileSource);
var binData;
xmlhttp = new ActiveXObject("msxml2.xmlhttp");
xmlhttp.Open("get",FileSource,false);
xmlhttp.Send();
binData=xmlhttp.ResponseBody;
var objsm = new ActiveXObject("ADODB.STREAM");
objsm.Type=1;
objsm.Open();
objsm.Write(binData);
objsm.SaveToFile(filename,2);
objsm.Close();
word = new ActiveXObject("word.application");
word.Visible = true;
word.documents.open(filename);
}catch(e){ShowErrorMsg(e);};
}
function SaveWeb(){
try{
FileDesource = document.WebForm.FileDesource.value + "&ID=" + document.WebForm.ID.value + "&FileMode=" + document.WebForm.FileMode.value + "&FileType=" + document.WebForm.FileType.value;
if (document.WebForm.FileMode.value == "new"){
var Name;
if (Name=window.prompt("请输入文档名称!","")){
FileDesource = FileDesource + "&Name=" + Name
};
};
//alert(FileDesource);
if (word != null){
word.activedocument.save();
word.quit();
};
var binData
var objsm = new ActiveXObject("ADODB.STREAM");
objsm.Type=1;
objsm.Open();
objsm.LoadFromFile(filename);
binData=objsm.read(objsm.size);
objsm.Close
xmlhttp = new ActiveXObject("msxml2.xmlhttp");
xmlhttp.Open("post",FileDesource,false);
xmlhttp.Send(binData);
//document.WebForm.FileMode.value = "open";
history.go(-1);
}catch(e){ShowErrorMsg(e);};
}
function OpenLocal(){
try{
word.dialogs.item(80).show();
}catch(e){ShowErrorMsg(e);};
}
function SaveLocal(){
try{
//parent.frames.main.WebForm.WJOnlineEdit.SaveLocal();
word.Dialogs.Item(84).Show();
}catch(e){ShowErrorMsg(e);};
}
function ProtectDoc(){
try{
word.ActiveDocument.Protect(1);
}catch(e){ShowErrorMsg(e);};
}
function UnProtectDoc(){
try{
word.ActiveDocument.UnProtect();
}catch(e){ShowErrorMsg(e);};
}
function ShowDialog(index){
try{
word.Dialogs(index).Show();
}catch(e){ShowErrorMsg(e);};
}
//设定用户名
function SetUserName(){
try{
var UserName;
if (UserName=window.prompt("请输入文档编辑者的名称,程序将记录此编辑者对文档的编辑痕迹!", word.UserName)){
word.UserName="" + UserName + "";
};
}catch(e){ShowErrorMsg(e);};
}
//痕迹保留
function TrackRevisions(){
try{
word.ActiveDocument.TrackRevisions =!word.ActiveDocument.TrackRevisions;
}catch(e){ShowErrorMsg(e);};
}
//痕迹显示
function ShowRevisions(){
try{
word.ActiveDocument.ShowRevisions =!word.ActiveDocument.ShowRevisions;
}catch(e){ShowErrorMsg(e);};
}
function ShowErrorMsg(e){
debug = true;
if (debug) {
alert(e.message);
}
}
//-->
</SCRIPT>