打开一个word文件后,打开数据库文件出错(100分)

L

linsb

Unregistered / Unconfirmed
GUEST, unregistred user!
if opendialog1.execute then begin
filename := OpenDialog1.filename;
WordApplication1.Connect;
WordApplication1.Visible := True;
confirmconversions := false;
readonly := false;
addtorecentfiles := false;
revert := true;
passworddocument := '';
passwordtemplate := '';
writepassworddocument := '';
writepasswordtemplate := '';
format := wdopenformatdocument; // EmptyParam
wordapplication1.documents.open(filename, confirmconversions,
readonly, addtorecentfiles, passworddocument, passwordtemplate,
revert, writepassworddocument, writepasswordtemplate, EmptyParam);
itemindex := 1;
doc.connectto(wordapplication1.documents.item(itemindex));
wordapplication1.options.checkspellingasyoutype := false;
wordapplication1.options.checkgrammarasyoutype := false;
table1.open;// 该语句出错,找不到路径!
end;
出错语句放到第一行不出错,请问为什么?,如果必须放在后,如何不出错?
Email:linsb3031@mail.china.com
 
你先要指定table1的路径,这样就不会出错了。
即当前的路径为table1的路径
 
sowrd_liu:
'指定table1的路径'是指数据库所在的路径吗?
 
在database的params加入
PATH=
DEFAULT DRIVER=PARADOX
ENABLE BCD=FALSE
再在在form的create事件中加入。
DataBase1.Params.Values['PATH']:=ExtractFilePath(Application.ExeName);

前提是你用的数据控件是database和table

如果不是,你可以指定数据库的路径。
因为你读word文件时改变了当前路径
 
sword_liu:
我已解决,加了语句: ChDir(sDir);‘sDir’为执行程序所在路径,谢谢提示。
 
顶部