请教一个有关OLE Automation Server封装Word操作的问题? (100分)

  • 主题发起人 主题发起人 huweimail
  • 开始时间 开始时间
H

huweimail

Unregistered / Unconfirmed
GUEST, unregistred user!

我建立了一个ActiveX库(ActiveX Library),然后新建了一个ActiveX Server
Object,代码如下

unit MyWord;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
ComObj, ActiveX, AspTlb, MyWordDocu_TLB, StdVcl;

type
Tword = class(TASPObject, Iword)
protected
WordDocument : Variant;
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure WordCreate; safecall;
end;

implementation

uses ComServ;

procedure Tword.OnEndPage;
begin
inherited OnEndPage;
end;

procedure Tword.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;

procedure Tword.WordCreate;
Var
FileName : string;
begin
FileName := Request.Form.Item['TextField'];
Response.write(FileName);
Response.Write('<BR>');
WordDocument := CreateOleObject('Word.Application');
//WordDocument.ActiveDocument.Content.InsertAfter('Insert');
//WordDocument.Documents.SaveAs('e:/inetpub/wwwroot/test.doc');
WordDocument.Quit;
end;

initialization
TAutoObjectFactory.Create(ComServer, Tword, Class_word,
ciMultiInstance, tmApartment);
end.

现在的问题是编译DLL、注册、ASP调用一切正常,但一旦将Tword.WordCreate方法
中那两条已经注释掉的语句加进去重新编译后,ASP就报500错误,难道Word对象除了创
建和退出之外,在Automation Server里什么也不能做吗?可我以前在普通的Application
里调用Word一切正常啊?
请高手指点迷津。
 
接受答案了.
 
后退
顶部