我正在构建一个小型web应用程序,它需要通过ActiveX和Javascript (和IE9.)访问Powerpoint。若要自动生成报表,请执行以下操作。我使用ActiveX是因为我无法在服务器端生成Powerpoint文件(尽管我非常喜欢这样)。
当我刚刚开始的时候,我的代码非常简单:
// Creating the ActiveX Powerpoint control
var ppt;
try{
ppt = new ActiveXObject("Powerpoint.Application");
}catch(e){
if (e instanceof ReferenceError)
alert("Your browser might not be compatible with this function. Please use Internet Explorer.");
else
alert("An error happened: " + e);
}
console.log("ActiveX Object created");
// Openning Powerpoint, make it visible
ppt.Visible = 1;
// Creating a new Presentation, and adding a blank (1 slide, 1 = ppLayoutBlank) Slide
ppt.Presentations.Add();
ppt.ActivePresentation.Slides.Add(1, 1);在我的计算机上,ActiveX控件不启动Powerpoint,即使我允许它通过"An ActiveX control on this page might be dangerous; Do you allow it to execute?"执行(直接从法语导出)。
但是,如果我启动Developper控制台,它就会神奇地运行。而且,在另一台带有IE11的计算机上,在我允许ActiveX控件执行之后,它可以正常工作。
我认为我的IE安全设置是正确的,因此我想不出任何其他我不知道的IE故障。我正在使用IE9.0.8112.16421 64位。
,我怎么能让这段代码运行得很好呢?,谢谢!
发布于 2015-01-14 14:54:53
提醒: IE中的console.log只在开发者控制台打开时才能工作。如果开发人员控制台关闭,它将停止脚本,因为console是undefined。
在代码中,尝试更改:
console.log("ActiveX Object created");
使用
try{console.log("ActiveX Object created")}catch(err){}或用://注释行。
https://stackoverflow.com/questions/27945553
复制相似问题