这篇翻译不完整。请帮忙从英语翻译这篇文章

警告: 该对象是微软的私有拓展名, 只在微软的IE浏览器上支持, 在win8的应用商店下载的其他浏览器应用也不被支持.

ActiveXObject 启用会返回一个自动化对象的引用

这个对象只能用于实例化自动化对象,它没有任何成员对象.

语法

let newObj = new ActiveXObject(servername, typename[, location])  

参数

servername
提供对象的应用程序的名称。
typename
要创建的对象的类型或类。
location 可选
要创建对象的网络服务器的名称。

备注

自动化服务器提供至少一种类型的对象。例如,文字处理应用程序可以提供应用程序对象、文档对象和工具栏对象。

您可以在HKEY_CLASSES_ROOT注册注册表项中识别主机PC上的servername.typename的值。下面是您可以找到的一些示例,它们要取决于你的电脑安装了哪些程序:

  • Excel.Application

  • Excel.Chart

  • Scripting.FileSystemObject

  • WScript.Shell

  • Word.Document

注意: ActiveX 对象可能会出现安全问题。要使用ActiveXObject, 你可能需要调整IE浏览器的相关安全区域的安全设置。比如说,对于本地局域网,你通常需要将自定义设置更改为"对未标记为可安全执行脚本ActiveX控件执行初始化并执行脚本"。

To identify members of an automation object that you can use in your code, you may need to use a COM object browser, such as the OLE/COM Object Viewer, if no reference documentation is available for the Automation object.

To create an Automation object, assign the new ActiveXObject to an object variable:

var ExcelApp = new ActiveXObject("Excel.Application");  
var ExcelSheet = new ActiveXObject("Excel.Sheet");

This code starts the application creating the object (in this case, a Microsoft Excel worksheet). Once an object is created, you refer to it in code using the object variable you defined. In the following example, you access properties and methods of the new object using the object variable ExcelSheet and other Excel objects, including the application object and the ActiveSheet.Cells collection.

// Make Excel visible through the Application object.  
ExcelSheet.Application.Visible = true;  
// Place some text in the first cell of the sheet.  
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";  
// Save the sheet.  
ExcelSheet.SaveAs("C:\\TEST.XLS");  
// Close Excel with the Quit method on the Application object.  
ExcelSheet.Application.Quit();

Requirements

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.x Store apps.

Note: Creating an ActiveXObject on a remote server is not supported in Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, Internet Explorer 11 standards mode, and Windows Store apps or later.

See also

文档标签和贡献者

此页面的贡献者: AubreyLing, zxz1992
最后编辑者: AubreyLing,