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("servername.typename"[, "location"])

The ActiveXObject object syntax and has these parts:

Part Description
servername Required. The name of the application providing the object.
typenameRequired. The type or class of the object to create.
locationOptional. The name of the network server where the object is to be created.

Remarks
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 ExcelSheet;
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. For example:

// 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();	
// Release the object variable.						
ExcelSheet = "";									
Creating an object on a remote server can only be accomplished when Internet security is turned off. You can create an object on a remote networked computer by passing the name of the computer to the servername argument of ActiveXObject. That name is the same as the machine name portion of a sharename. For a network share named "\\myserver\public", the servername is "myserver". In addition, you can specify servername using DNS format or an IP address.

The following code returns the version number of an instance of Excel running on a remote network computer named "myserver":

Function GetVersion {
  var XLApp = CreateObject("Excel.Application", "MyServer");
  return(XLApp.Version);
}
An error occurs if the specified remote server does not exist or cannot be found.