...retrieve the Text of all Text Boxes in a Word Document?
Author: Thomas Stutz
uses
ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
MSWord: OLEVariant;
sText: string;
i: Integer;
begin
try
// active word instance
MSWord := GetActiveOleObject('Word.Application');
except
Exit; // Word not open
end;
for i := 1 to MSWord.ActiveDocument.Shapes.Count do
begin
sText := MSWord.ActiveDocument.Shapes.Item(i).TextFrame.TextRange;
sText := StringReplace(sText, #$D, #13#10, [rfReplaceAll]);
Memo1.Lines.Add(sText);
end;
MSWord := Unassigned;
end;
printed from
www.swissdelphicenter.ch
developers knowledge base