E
eprun
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个将word 2000文档转换成html的asp组件,但是运行时出错
'Doc2htm.Doc2HtmObject 错误 '8000ffff'
Variant does not reference an automation object
/jy/test1.asp, 行6'
asp代码如下:
<%
dim myhtml
set myhtml=server.createobject("Doc2Htm.Doc2Htmobject")
myhtml.DocName="g:/inetput/wwwroot/jy/111.Doc"
myhtml.HtmSaveName="g:/inetput/wwwroot/jy/111.Htm"
myhtml.Doc2HtmExecute '<-- 出错的行
set myhtml=nothing
%>
delphi代码如下:
unit Unit1;
interface
uses
ComObj, ActiveX, Word_TLB, AspTlb, Doc2htm_TLB, StdVcl;
type
TDoc2HtmObject = class(TASPObject, IDoc2HtmObject)
private
MyDocName:string;
MyHtmName:string;
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
function Get_DocName: WideString
safecall;
procedure Set_DocName(const Value: WideString)
safecall;
function Get_HtmSaveName: WideString
safecall;
procedure Set_HtmSaveName(const Value: WideString)
safecall;
procedure Doc2HtmExecute
safecall;
end;
implementation
uses ComServ;
procedure TDoc2HtmObject.OnEndPage;
begin
inherited OnEndPage;
end;
procedure TDoc2HtmObject.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
MyDocName:='';
MyHtmName:='';
end;
function TDoc2HtmObject.Get_DocName: WideString;
begin
result:=MyDocName;
end;
procedure TDoc2HtmObject.Set_DocName(const Value: WideString);
begin
MyDocName:=value;
end;
function TDoc2HtmObject.Get_HtmSaveName: WideString;
begin
result:=MyHtmName;
end;
procedure TDoc2HtmObject.Set_HtmSaveName(const Value: WideString);
begin
MyHtmName:=value;
end;
procedure TDoc2HtmObject.Doc2HtmExecute;
var
wrd:OleVariant;
Dc:OleVariant;
begin
wrd:=createoleobject('word.Application');
wrd.visible:=false;
try
Dc := Wrd.Documents.open(MyDocName);
wrd.ActiveDocument.SaveAs(MyHtmName,wdFormatHTML);
finally
Dc.Close(false);
Wrd.Quit(False);
end;
end;
initialization
TAutoObjectFactory.Create(ComServer, TDoc2HtmObject, Class_Doc2HtmObject,
ciMultiInstance, tmApartment);
end.
'Doc2htm.Doc2HtmObject 错误 '8000ffff'
Variant does not reference an automation object
/jy/test1.asp, 行6'
asp代码如下:
<%
dim myhtml
set myhtml=server.createobject("Doc2Htm.Doc2Htmobject")
myhtml.DocName="g:/inetput/wwwroot/jy/111.Doc"
myhtml.HtmSaveName="g:/inetput/wwwroot/jy/111.Htm"
myhtml.Doc2HtmExecute '<-- 出错的行
set myhtml=nothing
%>
delphi代码如下:
unit Unit1;
interface
uses
ComObj, ActiveX, Word_TLB, AspTlb, Doc2htm_TLB, StdVcl;
type
TDoc2HtmObject = class(TASPObject, IDoc2HtmObject)
private
MyDocName:string;
MyHtmName:string;
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
function Get_DocName: WideString
safecall;
procedure Set_DocName(const Value: WideString)
safecall;
function Get_HtmSaveName: WideString
safecall;
procedure Set_HtmSaveName(const Value: WideString)
safecall;
procedure Doc2HtmExecute
safecall;
end;
implementation
uses ComServ;
procedure TDoc2HtmObject.OnEndPage;
begin
inherited OnEndPage;
end;
procedure TDoc2HtmObject.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
MyDocName:='';
MyHtmName:='';
end;
function TDoc2HtmObject.Get_DocName: WideString;
begin
result:=MyDocName;
end;
procedure TDoc2HtmObject.Set_DocName(const Value: WideString);
begin
MyDocName:=value;
end;
function TDoc2HtmObject.Get_HtmSaveName: WideString;
begin
result:=MyHtmName;
end;
procedure TDoc2HtmObject.Set_HtmSaveName(const Value: WideString);
begin
MyHtmName:=value;
end;
procedure TDoc2HtmObject.Doc2HtmExecute;
var
wrd:OleVariant;
Dc:OleVariant;
begin
wrd:=createoleobject('word.Application');
wrd.visible:=false;
try
Dc := Wrd.Documents.open(MyDocName);
wrd.ActiveDocument.SaveAs(MyHtmName,wdFormatHTML);
finally
Dc.Close(false);
Wrd.Quit(False);
end;
end;
initialization
TAutoObjectFactory.Create(ComServer, TDoc2HtmObject, Class_Doc2HtmObject,
ciMultiInstance, tmApartment);
end.