如何使用IE中的javascript检测安装的MS Office版本?

时间:2013-07-19 13:42:10

标签: javascript internet-explorer ms-office office-2013

其实我需要知道是否安装了2013版的MS Office。 方法

var oApplication=new ActiveXObject("Word.Application");

对我来说不适用于网站(但是从本地磁盘运行时它可以正常工作)。

3 个答案:

答案 0 :(得分:2)

我在Office365中调试过:
ms-powerpoint:ofe | u | https:// .... =>简报
ms-word:ofe | u | https:// =>字
ms-excel:ofe | u | https:// => Excel

答案 1 :(得分:1)

您无法从IE中的Internet区域(并且Office应用程序不是SFS)实例化未标记为“Safe for Scripting”的ActiveX控件。

您在Office 2013之前使用了什么“旧机制”以及您打算使用什么“新机制”?

(请记住,SharePoint可以在没有版本检测的情况下正常使用新旧Office客户端。)

答案 2 :(得分:1)

Okey,所以答案是这样的(SharePoint可以正常使用没有版本检测的新旧Office客户端,因此必须有解决方案)

try {
    var g = new ActiveXObject("SharePoint.OpenDocuments.5");
    alert('Office 2013 installed');
    window.open('ms-word:ofe|u|http://server.com/12.docx');
}
catch (h) {
    alert('Office 2010/older installed');
    var g = new ActiveXObject("SharePoint.OpenDocuments");
    g.EditDocument('http://server.com/12.docx');
}

唯一的问题是在“受保护的视图”中打开文档,而SharePoint会在常规视图中打开它们。