Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Delphi7 und MSWord - word.Selection (https://www.delphipraxis.net/132018-delphi7-und-msword-word-selection.html)

erich.wanker 4. Apr 2009 14:33


Delphi7 und MSWord - word.Selection
 
Hallo Leute,

wenn ich via Delphi-Code im Word einen text suche und markiere - kann ich den text aus einer DB ins Word schreiben..

Wenn aber das "Feld im Word" gar nicht existiert soll kein text eingefügt werden ..
ich suche so eine Art: "If word.selection.selectedText.count > 0 then ..."

Jemand eine Idee?

thanX

Erich



Delphi-Quellcode:
...

    word.Selection.Find.ClearFormatting;
    word.Selection.Find.Text:='<<Feld>>';
    word.Selection.Find.Replacement.Text:='';
    word.Selection.Find.Forward:=true;
    word.Selection.Find.Format:=false;
    word.Selection.Find.MatchCase:=false;
    word.Selection.Find.MatchWholeWord:=false;
    word.Selection.Find.MatchWildcards:=false;
    word.Selection.Find.MatchSoundsLike:=false;
    word.Selection.Find.MatchAllWordForms:=false;
    word.Selection.Find.Execute;

    word.Selection.TypeText (Text := '..wurde ersetzt' );
    word.Selection.TypeParagraph;

...

toms 4. Apr 2009 14:43

Re: Delphi7 und MSWord - word.Selection
 
Meinst du was was?

Delphi-Quellcode:
...
..
    word.Selection.Find.Execute;
    if word.Selection.Find.Found then
    begin
      word.Selection.TypeText (Text := '..wurde ersetzt' );
      word.Selection.TypeParagraph;
    end;
...

erich.wanker 4. Apr 2009 15:07

Re: Delphi7 und MSWord - word.Selection
 
..genau das

.. find.found .. da muß man mal draufkommen ;-)


Vielen Dank

toms 4. Apr 2009 15:09

Re: Delphi7 und MSWord - word.Selection
 
Zitat:

Zitat von erich.wanker
..genau das

.. find.found .. da muß man mal draufkommen ;-)

Ich habe nichts anderes gemacht als in der MS Word VBA Referenz nachgeschaut.


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