Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2004, 04:31 PM
agent86 agent86 is offline
Senior Member
 
Join Date: Jan 2002
Posts: 1,192
Default Sloooow load of DBRichEdit into MS Word

Delphi 7 Pro
MS SQL 2000
MS Word 2000

1. I write DBRichEdit text to file.
2. Start Word.
3. Load file.
4. I save it in RTF format.
5. Display the form.
6. Make changes.
7. Save rtf document.
8. Close Word.
9. Load edited file back into DBRichEdit.

The first time I send the DBRichEdit to Word, it takes about 30 seconds. After performing the above routine, it only takes about 2 seconds to load it to Word the next time.

30 seconds is too long to be practical. Any suggestions to speed up the first load of the file to Word?

Here is the applicable code.

<ct>
procedure TTeachSetEditorForm.ClinicalHistoryEditSpeedButton Click(Sender: TObject);
begin
CreateClinicalHistoryRTFTempFile ;
EditClinicalHistoryTempDocInWord ;
end;
</ct>
<cb>
Procedure TTeachSetEditorForm.CreateClinicalHistoryRTFTempFi le ;
var
filename, exedir, docname : string;
begin
{create a temporary file}
// where is the program folder?
exedir := ExtractFilePath(Application.ExeName) ;

docname := 'ch' +
DMSTDB.EditTeachSetPatientADOTable.FieldbyName('ID _Number').value ;
filename := exedir + 'tempdocs\' + docname + '.rtf' ;

with ClinicalHistoryDBRichEdit do
TBlobField(

DMSTDB.EditTeachSetPatientADOTable.FieldByName('Cl inicalHistory')).SaveToFile(filename);
end;
</cb>
<ct>
procedure TTeachSetEditorForm.EditClinicalHistoryTempDocInWo rd ;
var
Word: OleVariant;
Doc: OleVariant;
filename, exedir, docname : string ;
begin

try
Word := CreateOleObject('Word.Application');
except
ShowMessage('Cannot start Word !');
VisibleFalseRefreshClinicalHistorySpeedButton ;
Exit;
end;

exedir := ExtractFilePath(Application.ExeName) ;

docname := 'ch' +
DMSTDB.EditTeachSetPatientADOTable.FieldbyName('ID _Number').value ;
filename := exedir + 'tempdocs\' + docname + '.rtf' ;

Word.Documents.Open(FileName);
Doc := Word.ActiveDocument;
// we save immediately to confirm we are in rtf format
// an empty data field would not automatically come over as rtf
Doc.SaveAs(FileName, wdFormatRTF);
Word.Visible := True ;

end ;
</ct>
<cb>
procedure TTeachSetEditorForm.ReadClinicalHistoryTempDocInto RTF ;
var filename, exedir, docname : string ;
begin
DMSTDB.EditTeachSetPatientADOTable.Edit ;
exedir := ExtractFilePath(Application.ExeName) ;

docname := 'ch' +
DMSTDB.EditTeachSetPatientADOTable.FieldbyName('ID _Number').value ;
filename := exedir + 'tempdocs\' + docname + '.rtf' ;

ClinicalHistoryDBRichEdit.PlainText := False ;
ClinicalHistoryDBRichEdit.Lines.LoadFromFile(FileN ame);
DMSTDB.EditTeachSetPatientADOTable.Post ;
end ;
</cb>


Donald Adams
Agent86
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:17 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.