Einzelnen Beitrag anzeigen

striderx

Registriert seit: 11. Feb 2007
Ort: Bergisch Gladbach
206 Beiträge
 
Delphi 10.4 Sydney
 
#1

Excel Object-Text lesen

  Alt 11. Dez 2020, 06:57
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:

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;

Geändert von striderx (11. Dez 2020 um 07:48 Uhr)
  Mit Zitat antworten Zitat