Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Die Delphi-IDE (https://www.delphipraxis.net/62-die-delphi-ide/)
-   -   Word mit OLE-Automation steuern (https://www.delphipraxis.net/70988-word-mit-ole-automation-steuern.html)

grf-irn 7. Jun 2006 16:40


Word mit OLE-Automation steuern
 
Kleine hoffentlich einfache Frage. Ich habe Word über OLE gestartet und
möchte nun gern den varianlen(###Pat&) durch text aus meine Programme ersetzen mit deise Funktion:

Delphi-Quellcode:
function FindenUndInsert(FindText, ReplacementText : string ) : boolean;
const wdReplaceAll = 2;
    begin
         WordApp.Selection.Find.Text := FindText;

         WordApp.Selection.Replacement.Text := ReplacementText;

         FindenUndInsert := WordApp.Selection.Find.Execute(Replace := wdReplaceAll);

    end;


procedure TfrmDocument.BitBtn12Click(Sender: TObject);

    Function CreateWord:boolean;
    begin
         CreateWord:=true;
         try
         W:=CreateOleObject('Word.Application');
         except
         CreateWord:=false;
         end;
    End;

    Function AddDoc:boolean;
    Var Doc_:variant;
    begin
         AddDoc:=true;
         try

         Doc_:=W.Documents.Add(ApplicationDir + BriefeDir + 'Standardtumorbrief.dot');
         //Doc_.Add;
         except
         AddDoc:=false;
         end;
    End;

begin
if CreateWord then
     begin
          If AddDoc then
          begin
               try

               FindenUndInsert('###Pat&', 'TEXT');

               except
                     On E:Exception do
                     begin
                         MyDialog.Msg('Fehler', E.Message + 'Fehler!', mb_ICONExclamation);
                     end;
               end;
          end;
       end;
end;

dann kommt FEHLER!!!!
"Metod 'Replacement' not supported by automation object".............. :-(((((((

Viele Dank im Voraus!

[edit=sakura] [delphi]/Tags Mfg, sakura[/edit]

Jens Schumann 7. Jun 2006 16:45

Re: Word mit OLE-Automation steuern
 
Zitat:

Zitat von grf-irn
WordApp.Selection.Replacement.Text := ReplacementText;

Versuche es mal mit
Delphi-Quellcode:
WordApp.Selection.Find.Replacement.Text := ReplacementText
[edit]Innerhalb von 5 Minuten in VBAWD10.CHM gefunden :wink: [/edit]

grf-irn 7. Jun 2006 17:01

Re: Word mit OLE-Automation steuern
 
Ich danke DIR!!!!!!!


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:43 Uhr.

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