Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Excel Object-Text lesen (https://www.delphipraxis.net/206333-excel-object-text-lesen.html)

striderx 11. Dez 2020 06:57

Excel Object-Text lesen
 
Ich versuche, bei Objekten in einer Excel 2003 Tabelle die Texte auszulesen, und zwar für AutoShapes, Textboxen und Wordart.

Bei den Textboxen klapp das problemlos mit:

Delphi-Quellcode:
AShape.TextFrame.Characters.Text
In den anderen beiden Fällen Fälle bekomme ich die Exception EVariantInvalidOpError.


Hat jemand einen Tipp?


Delphi-Quellcode:
 
var
  AShape: Variant;
  AType:  Integer;

 
for I := 1 to Excel.ActiveSheet.Shapes.Count do begin
    AShape := Excel.ActiveSheet.Shapes[I];
    AType := AShape.Type;
    case AType of
       1: if AShape.TextFrame.Characters.Text <> '' then begin              // msoAutoShape
              Inc(NumShapes);
              Inc(NumAutoShapes);
           end;
      15: if AShape.TextFrame.Characters.Text <> '' then begin              // msoTextEffect
              Inc(NumShapes);
              Inc(NumTextEffects);
           end;
      17: if AShape.TextFrame.Characters.Text <> '' then begin              // msoTextBox
              Inc(NumShapes);
              Inc(NumTextBoxes);
           end;
      end;
  end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:16 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz