Activexobject function details
2010-03-03 19:00:02| Category:
It Knowledge Base| Tag:
|Font SizeLargeMediumSmall Subscription
What is ActiveX Control? ActiveX controls are widely used in the Internet. They can increase browsing pleasure by providing videos and animated content. However Program Problems may occur or unnecessary content is provided to you. In some cases, these programs can be used to collect information from your computer, damage data on your computer, install software on your computer without your consent, or allow others remotely control your computer. With these risks in mind, you should install these programs with full trust in the publisher. What do you do when Windows blocks the installation of ActiveX controls? You may not install the ActiveX control. Installing ActiveX controls blocked by Windows is an extremely risky task. If the security settings of Internet Explorer are at the default level and the ActiveX control does not have a valid digital signature, Windows will prevent the installation of this ActiveX control. A valid digital signature identifies the publisher (the company, website, or individual distributing the document) and confirms the fact that the document has not been tampered with since its signature. If the file does not have a valid digital signature, you cannot determine whether the file actually comes from the source it declares, or whether it has not been tampered with (for example, a virus may be inserted into the control ). Unless you trust the publisher and know that the file is safe after it is opened, you should not open the file. Activexobject usage instructions: javas Activexobject in automation is enabled and returns a reference to the Automation Object. Usage:Newobj = new activexobject (servername. typename [, location]) The activexobject object syntax includes these parts: newobj is a required parameter. Variable name to be assigned to activexobject. Servername is required. Provide the name of the application of the object. Typename is required. The type or class of the object to be created. Location is optional. Name of the network server where the object is created. The Automation server provides at least one type of objects. For example, a word processing application may provide application objects, document objects, and toolbar objects. For example, to create an Excel application and sheet object, Code As follows:
VaR excelapp = new activexobject ("Excel. application ");
VaR excelsheet = new activexobject ("Excel. Sheet ")
Once an object is created, it can be referenced in the code using the defined object variable. Next we will look at the reference to the object and method through an example, access the attributes and methods of the new object through the object variable excelsheet and other Excel objects, including the Application Object and activesheet. cells set. The Code is as follows:
1 excelsheet. application. Visible = true;
2 excelsheet. activesheet. cells (1, 1). value = "this is column A, Row 1 ";
3 excelsheet. saveas ("C: \ test. xls ");
4 excelsheet. application. Quit ();
Next let's take a look at how to create an object on the remote server, but there is a premise to disable Internet security. To create an object on a remote network computer, you can pass the name of the computer to the servername parameter of activexobject. The name is the same as the machine name part of the shared name. For example, if you share a network named "\ myserver \ public", servername is "myserver ". In addition, you can specify servername in DNS format or IP address. The following code returns"
The Excel instance version number running on the remote network computer:
1 function getappversion (){
2 var xlapp = new activexobject ("Excel. Application", "myserver ");
3 return (xlapp. version );
4}
If the specified remote server does not exist or cannot be found, an error will occur.