用Delphi6开发调用Word的DLL,出现“标示没有引用”的错误!(50分)

  • 主题发起人 xuepiaofei
  • 开始时间
X

xuepiaofei

Unregistered / Unconfirmed
GUEST, unregistred user!
动态连结库源代码:
library WordDll;

uses
Messages, SysUtils, Classes,Dialogs, StdCtrls,//系统
Variants,ComObj,Word_TLB;//自添加

var
mWordObj,mWordDoc:Variant;
OpenFlag:Boolean;


{------------------ 打开一个Word文档 ----------------------}
procedure OpenWordFile(FileName:pChar);StdCall;
var
IndexDoc:integer;
mFileName:String;
begin
try
if not OpenFlag then begin
mWordObj:=CreateOleObject('Word.Application');//出错!!
OpenFlag:=True;
end;
mFileName:=FileName;
mWordObj.Application.Documents.open(mFileName);
mWordObj.Application.Visible:=True;
IndexDoc:=mWordObj.Application.Documents.count;
mWordDoc:=mWordObj.Application.Documents.item(IndexDoc);
except
on e:Exception do begin
ShowMessage(e.Message);
Abort;
end;
end;
end;

………………
………………

{------------ exports -----------------------------}
exports
OpenWordFile;//打开Word

{------------- DLL入口:进行全局变量初始化 ---------------}
begin
OpenFlag:=False;
mWordObj:=null;
mWordDoc:=null;
end.


出现的问题:
在调试的时候,出现'标记没有引用存储'.的错误信息;
经调试,错误出在CreateOleObject('Word.Application')上,
似乎在DLL中无法识别到Word.Application这个ClassName,
请教各位大侠该怎么解决?
 
用CreateOle的方法不需要引入Word_TLB
 
接受答案了.
 
顶部