Microsoft JScript
ActiveXObject Object
Language Reference
Version 3

See Also


Description
Enables and returns a reference to an Automation object.
Syntax
var newObject = new ActiveXObject(class)

The class argument uses the syntax servername.typename and has these parts:

Part Description
servername The name of the app providing the object.
typename The type or class of the object to create.
Remarks
Automation servers provide at least one type of object. For example, a word-processing app may provide an app object, a document object, and a toolbar object.

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


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


This code starts the app 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 app object and the ActiveSheet.Cells collection. For example:

// Make Excel visible through the app object.
ExcelSheet.app.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 app object.
ExcelSheet.app.Quit();
// Release the object variable.
ExcelSheet = "";



Comments