Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Text bei Cursor??? DelphiXE (https://www.delphipraxis.net/162010-text-bei-cursor-delphixe.html)

Beck93 2. Aug 2011 08:21

Text bei Cursor??? DelphiXE
 
Hi,

Ich hoffe mal ich bin hier richtig da das mein erster Beitrag ist?:lol:

Ich stehe vor dem Problem, dass ich rausfinden muss ob in Word an der aktuellen Cursor Position schon Text steht oder nicht?

Nur weiß ich leider nicht wie? bin für jede Hilfe dankebar.

Danke

Beck93

p80286 2. Aug 2011 09:24

AW: Text bei Cursor??? DelphiXE
 
Die richtige Antwort wäre: nie, da der Cursor immer zwischen zwei Zeichenpositionen (oder vor oder hinter ) steht.

Könntest Du vieleicht noch ein paar Informationen geben?
Wahrscheinlich suchst Du nach Selection und/oder Range.

Gruß
K-H

Beck93 2. Aug 2011 09:32

AW: Text bei Cursor??? DelphiXE
 
Oke dann ob noch kein Text hinter dem Cursor steht:wink:

Zu den näheren Informationen:

Ich habe ein Word dokument mit einer Tabelle. In der ersten Zelle ist eine Textmarke an die ich springe nach dem öffnen des Dokumentes.
Nun will ich wissen ob in dieser Zelle schon Text steht oder noch nicht?
Wenn Text vorhanden ist gehe ich eine Zelle nach unten und möchte dort wieder auf vorhandenen Text Prüfen?

Ich hoffe Das hilft ein wenig.

Danke

Gruß
Beck93

Hier noch nachträglich ein Ausschnitt aus dem Quelltext vieleicht hilft das auch.

Code:
 
  try
    WordObj := ComObj.CreateOleObject('Word.Application');
    WordObj.documents.open(Exe);
    Doc := WordObj.ActiveDocument;
  except
    ShowMessage('Die Datei konnte nicht geöffnet werden!');
    Exit;
  end;

  if Doc.Bookmarks.Exists(Bookmark) then
  begin
     Doc.Bookmarks.Item(Bookmark).Select;
    for I := 6 to 24 do
    begin
     if WordObj.Selection.Find.Text = '' then //hier ist der Fehler
      begin
        leer := true;
        if Form1.edtDatumBis.Text = Form1.edtDatumVon.Text then
          WordObj.Selection.TypeText(Text:= Form1.edtDatumVon.Text)
        else
        begin
          WordObj.Selection.TypeText(Text := Form1.edtDatumVon.Text + ' ' +
            Form1.edtDatumBis.Text);
        end;
        WordObj.Selection.MoveRight;

p80286 2. Aug 2011 10:43

AW: Text bei Cursor??? DelphiXE
 
Versuch es doch mal hiermit:
Delphi-Quellcode:
mychktext:=WordObj.Selection.Text;
mychktext:=Trim(mychktext);
if length(mychktext>0 then { es gibt Text}
else                      { es gibt keinen Text}
Gruß
K-H

Beck93 2. Aug 2011 12:29

AW: Text bei Cursor??? DelphiXE
 
Super genau danach hab ich gesucht.

Danke

Gruß

Beck93


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:40 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