Hi,
I have a few thousand .doc files all filled in with data following a pretty simple pattern/template.
Example:
Code:
NAME:
SURNAME:
AGE:
ADDRESS:
DATE:
I'd like to open the .doc in my delphi application, search for NAME: then identify, select and copy to clipboard EVERY BIT of text that starts right after NAME: all the way to where SURNAME: starts.
Example:
Code:
NAME: JOSH
SURNAME: JIM
It should copy JOSH to the clipboard.
Example #2:
Code:
NAME: JOSH
JOSH
SURNAME: JIM
It should copy JOSH JOSH to the clipboard.
Example #3:
Code:
NAME: JOSH JOSH
JOSH
SURNAME: JIM
It should copy JOSH JOSH JOSH to the clipboard.
Basically, should start copying everything starting right after : from the NAME: and stop right before S from/where SURNAME: starts.
Code so far:
Code:
procedure TForm1.Button2Click(Sender: TObject);
var
WordApp : Variant;
TextToFind : String;
i: integer;
fname: string;
begin
WordApp := CreateOleObject('Word.Application');
WordApp.Visible := True;
for i := 1 to 3 do
begin
fname := Memo1.Lines[i - 1];
Wordapp.Documents.Open('C:\Users\tcsh\Desktop\A\'+fname);
TextToFind :='NAME:';
WordApp.Selection.Find.Execute(TextToFind);
WordApp.Selection.Copy;
Memo2.SetFocus;
Memo2.PasteFromClipboard;
end;
end;
Managed to locate the .doc, open it, find NAME: and select it, copy it and paste it in Memo2 from the clipboard. Obviously, I need the text after NAME: as explained above and that's where I'm stuck.
Could anyone add to the code so I can get this done ?
Appreciate it.