var ExcelSheet;
var wordflag=0;
var myRange
function OpenWord()
{
onerror=errormsg;
ExcelSheet = new ActiveXObject("Word.Application");
ExcelSheet.Application.Visible = true;
var mydoc=ExcelSheet.Documents.Add("",0,1);
myRange =mydoc.Range(0,1)
if(myiframe.document.body.innerText=="")
{
myiframe.document.body.innerText=" ";
}
var sel=myiframe.document.body.createTextRange()
sel.select()
myiframe.document.execCommand('Copy')
sel.moveEnd('character')
myRange.Paste();
ExcelSheet.ActiveWindow.ActivePane.View.Type=3
wordflag=1
}
function restoreimg()
{
var theimgstr=myiframe.document.body.innerHTML
var re=/(v:imagedata)/gi
theimgstr=theimgstr.replace(re,"img")
var re=/(o:href)/gi
theimgstr=theimgstr.replace(re,"src")
while(theimgstr.indexOf("\<v:shape")!=-1)
{
var starpos=theimgstr.indexOf("\<v:shape")
var endpos =theimgstr.indexOf("\>",starpos)+1
starpos=starpos
var midstr=theimgstr.substring(starpos,endpos)
theimgstr=theimgstr.replace(midstr,"")
}
myiframe.document.body.innerHTML=theimgstr
theimgstr=myiframe.document.body.innerHTML
if(theimgstr.indexOf("src\=\"file:\/\/\/")!=-1)
{
alert("程序发现您在Word中插入了本地图片\r请在编辑框中重新插入\r否则文档保存后图片将不可见")
}
}
function errormsg()
{
alert("请确认是否装有Word如果装有请确认\r是否IE的安全选项\"本地Intranet\"级别\r已被设为\"低\"否则将不能使用此功能,步骤如下:\r工具-\>Internet选项->安全\r-\>本地Intranet-\>自定义级别-\>第二项选为启用或提示");
return true;
}