How can I modify the text of an existing excel shape from Delphi?
I can create a new shape and set its text
procedure TForm1.Button1Click(Sender: TObject);
var
excel, xlShape : variant;
begin
olecontainer1.CreateObject('Excel.Application',false);
excel := olecontainer1.OleObject;
excel.workbooks.open('C:\test.xls');
XlShape := excel.application.worksheets[1].Shapes.AddShape(1, 0, 0, 450, 200);
XlShape.textframe.characters.text:='new shape created from Delphi';
But if the shape already exists, how can I select it to change its text property? Something like:
excel.application.worksheets[1].Shapes('shape1').textframe.characters.text := 'This gives error';