![]() |
Suchen und Ersetzen in Word Dokument
Ich schon wieder....
Ich will in einem Word Dokument den Text "01." (kommt paar hundertmal vor) durch "Januar" ersetzen:
Delphi-Quellcode:
Warum funzt das nicht???
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Word2000, OleServer, StdCtrls; type TForm1 = class(TForm) Button1: TButton; WordApplication1: TWordApplication; WordDocument1: TWordDocument; WordFont1: TWordFont; WordParagraphFormat1: TWordParagraphFormat; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; FileName: OleVariant; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin WordApplication1.Connect; FileName := 'e:\Delphi\Word\01.doc'; WordApplication1.Documents.Open(FileName, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam); WordApplication1.visible := true; end; procedure TForm1.Button2Click(Sender: TObject); var vAlt, vNeu: Variant; begin WordDocument1.ConnectTo(WordApplication1.ActiveDocument); vAlt := '01.'; vNeu := 'Januar'; WordApplication1.Selection.Find.Execute(vAlt,EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam, EmptyParam,EmptyParam, vNeu,EmptyParam); end; end. Vielen Dank schonmal... |
Re: Suchen und Ersetzen in Word Dokument
Zitat:
|
Re: Suchen und Ersetzen in Word Dokument
beim Compilieren kommen folgende Fehlermeldungen:
Zur Zeile WordApplication1.Selection.Find.Execute(vAlt,Empty Param,... //usw "Types of actual and formal var parameters must be identical" "Not enough actual parameters" |
Re: Suchen und Ersetzen in Word Dokument
Schau doch mal
![]() |
Re: Suchen und Ersetzen in Word Dokument
Hallo omata,
danke, das hatte ich auch schon gefunden, da sind aber zu viele Sachen drin, die ich nicht verstehe. Ich will Automation lernen und daher auch wissen, was ich mache und warum was funktioniert oder nicht. Gruß, |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:10 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