18 out of 34 rated this helpful - Rate this topic

ActiveXObject Object (JavaScript)

JavaScript - Internet Explorer 10

Enables and returns a reference to an Automation object.

This object is used only to instantiate Automation objects, and has no members.

Caution note Caution

This object is supported in Internet Explorer only, not in Windows Store apps.

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

Required. The variable name to which the ActiveXObject is assigned.

servername

Required. The name of the application providing the object.

typename

Required. The type or class of the object to create.

location

Optional. The name of the network server where the object is to be created.

Automation servers provide at least one type of object. For example, a word-processing application may provide an application object, a document object, and a toolbar 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();

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. Not supported in Windows Store apps. See JavaScript Version Information.

Note Note

Creating an ActiveXObject on a remote server is not supported in Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, and win8_appname_long apps or later.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.