var
FileName : TextFile;
Str,Tmp : String;
TStrList : TStringList;
i,k : Integer;
begin
TStrList := TStringList.Create;
TStrList.Clear;
if not (FileExists(GetNameDir(Application.ExeName)+'xuanhao.txt')) then
begin
Application.MessageBox('xuanhao.txt文件不存在,请先转出TXT文件','提示',MB_OK+MB_ICONSTOP);
Exit;
end;
AssignFile(FileName,GetNameDir(Application.ExeName) + 'xuanhao.txt');
Reset(FileName);
Readln(FileName,Str);
CloseFile(FileName);
if Str <> '' then
begin
i := pos(',',str);
while i > 0 do
begin
Tmp := copy(Str,1,i - 1);
TStrList.Add(Tmp);
Str := copy(Str,i + 1,length(Str)-i);
i := pos(',',Str);
end;
if Str <> '' then
begin
TStrList.Add(Str);
end;
end;
教你一个方法,在内存中打开DOC文件,或者是TXT文件,把所有的内容复制一下,再粘贴一下到MEMO1中,,
procedure TFraDoc.TvDocClick(Sender: TObject);
var
Word:Variant;
begin
if Tvdoc.Selected=nil then exit;
if not FileExists(SPath+'doc\'+TvDoc.Selected.Text+'.doc') then
begin
application.MessageBox('无此文档存在!',AppName,Gstitle);
exit;
end;
try
Word:=CreateOLeObject('Word.application');
Word.visible:=false;
Word.documents.add;
begin
word.selection.insertfile(SPath+'doc\'+TvDoc.Selected.Text+'.doc');
word.Selection.WholeStory;
word.Selection.Copy;
Redt.Lines.Clear;
Redt.PasteFromClipboard;
end;
finally
word.quit(false);
end;
end;