Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Scripting
 ActiveXObject Object
Collapse All/Expand All Collapse All
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
JScript
ActiveXObject Object (Windows Scripting - JScript)

Updated: April 2009

Enables and returns a reference to an Automation object.

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();

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 share name. 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 GetAppVersion() {
   var XLApp = new ActiveXObject("Excel.Application", "MyServer");
   return(XLApp.Version);
}

An error occurs if the specified remote server does not exist or cannot be found.

Date

History

Reason

April 2009

Modified syntax in example.

Customer feedback.

Community Content   What is Community Content?
Add new content RSS  Annotations
Error, "Automation server can't create object"      eceramanan ... Laxmi Narsimha Rao ORUGANTI MSFT   |   Edit   |   Show History
By default, browser would not aloow to create this object. Provided if user changes browser option Open IE -> Tools ->Internet Options -> Security -> Custom Level ->ActiveX controls and plug-ins ->Enable "Initialize and script ActiveX controls not marked as safe for scripting"
then it works....
Is there any other way to read an excell sheet at client end itself. I do not want to upload the excell to the server and read there. Instead i want to read it in client side and take the same to the server.

Is there any posiblity? if so kindly provide me with samples....


Thanks,
Ramanan R

[tfl - 10 08 09] Hi - and thanks for your post. You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn or the MSDN Newsgroups at
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker