以下代码,发布网站后正确,但在IDE中开始执行却显示"Automation 服务器不能创建对象"
开发工具是Visual Studio 2005
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<Script Language="JavaScript">
function Validator()
{
var wApp = new ActiveXObject("Word.Application.11");
wApp.Visible = true ;
wApp.Documents.Open( "HTTP://200.100.3.56/test/qq.doc" );
wApp.ActiveDocument.TrackRevisions = true ;
wApp.ActiveDocument.ShowRevisions = true ;
wApp.ActiveDocument.Application.UserName= "qiaoqun"; }
</script> </head>
<body>
<input type="button" name="word" value="word" onclick="Validator()">
</body>
</html>
开发工具是Visual Studio 2005
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<Script Language="JavaScript">
function Validator()
{
var wApp = new ActiveXObject("Word.Application.11");
wApp.Visible = true ;
wApp.Documents.Open( "HTTP://200.100.3.56/test/qq.doc" );
wApp.ActiveDocument.TrackRevisions = true ;
wApp.ActiveDocument.ShowRevisions = true ;
wApp.ActiveDocument.Application.UserName= "qiaoqun"; }
</script> </head>
<body>
<input type="button" name="word" value="word" onclick="Validator()">
</body>
</html>
创建XMLHTTPREQUEST对像的方法要不一样的.
比如:
var aj = new Object();
aj.statusId = statusId ? document.getElementById(statusId) : null;
aj.targetUrl = '';
aj.sendString = '';
aj.recvType = recvType ? recvType : 'XML';
aj.resultHandle = null; aj.createXMLHttpRequest = function() {
var request = false;
if(window.XMLHttpRequest) {
request = new XMLHttpRequest();
if(request.overrideMimeType) {
request.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject) {
var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
for(var i=0; i<versions.length; i++) {
try {
request = new ActiveXObject(versions[i]);
if(request) {
return request;
}
} catch(e) {
//alert(e.message);
}
}
}
return request;
} aj.XMLHttpRequest = aj.createXMLHttpRequest();
你把var wApp = new ActiveXObject("Word.Application.11"); 改成var wApp = new ActiveXObject("Word.Application"); 试试.