Einzelnen Beitrag anzeigen

ms6

Registriert seit: 22. Aug 2006
Ort: Bad Lauchstädt
5 Beiträge
 
#3

Re: Delphi steuert Word - Dokument unter anderem Name speich

  Alt 8. Sep 2006, 07:49
Hallo Guten Morgen!

Hat zwar ne Weile gedauert aber habs mal ausprobiert, allerdings bin ich nicht weiter gekommen
Hier mal der ursprüngliche Code, vielleicht kann mans ja doch anders machen?

if ckbKoepfe_erstellen.Checked then
begin
try
WordApp := CreateOleObject('Word.Application');
WordApp.Documents.Open(inFile);
except
ShowMessage('Cannot start Word or open document!');
Exit;
end;
Begin
Case i of
1: neuKopf:='AA';
2: neuKopf:='AB';
3: neukopf:='AG';
4: neukopf:='AI';
5: neukopf:='BV';
6: neukopf:='DS';
7: neukopf:='EV';
8: neuKopf:='EW';
9: neuKopf:='FA';
10: neuKopf:='FIG';
11: neuKopf:='GEW';
12: neuKopf:='GL';
13: neuKopf:='GS';
14: neuKopf:='GSA';
15: neuKopf:='GST';
16: neuKopf:='GV';
17: neuKopf:='IG';
18: neuKopf:='IHK';
19: neuKopf:='IN';
20: neuKopf:='IT';
21: neuKopf:='IV';
22: neuKopf:='KK';
23: neuKopf:='LAR';
24: neuKopf:='LG';
25: neuKopf:='LSG';
26: neuKopf:='OFD';
27: neuKopf:='OLG';
28: neuKopf:='OVG';
29: neuKopf:='SCD';
30: neuKopf:='SCGV';
31: neuKopf:='SCZB';
32: neuKopf:='SG';
33: neuKopf:='ST';
34: neuKopf:='STA';
35: neuKopf:='VG';
36: neuKopf:='VSA';
37: neuKopf:='WAG';
38: neuKopf:='WZV';
39: neuKopf:='ZAG';
40: neuKopf:='ZB';
41: neuKopf:='ZV';
42: neuKopf:='ZZV';
end; //Case
WordApp.Visible := true;
repeat
begin

WordApp.ActiveWindow.ActivePane.View.SeekView:=wdS eekFirstPageHeader;
WordApp.Selection.Find.ClearFormatting;
WordApp.Selection.Find.Replacement.ClearFormatting ;for i:=1 to 42 do
WordApp.Selection.Find.Text := 'SC' ;
WordApp.Selection.Find.Replacement.Text := 'AV'+neuKopf;
WordApp.Selection.Find.Forward := True;
WordApp.Selection.Find.Wrap := wdFindContinue;
WordApp.Selection.Find.Format := False;
WordApp.Selection.Find.MatchCase := False;
WordApp.Selection.Find.MatchWholeWord := False;
WordApp.Selection.Find.MatchWildcards := False;
WordApp.Selection.Find.MatchSoundsLike := False;
WordApp.Selection.Find.MatchAllWordForms := False;

if WordApp.Selection.Find.Execute() = true then
begin

WordApp.Selection.TypeText(Text:='AV'+neuKopf);

If (WordApp.ActiveWindow.ActivePane.View.Type = 1) Or
(WordApp.ActiveWindow.ActivePane.View.Type = 2) Then
WordApp.ActiveWindow.ActivePane.View.Type :=3;


end;
end;
until WordApp.Selection.Find.Execute()=false;
outfile:='KOPF'+neukopf+'.RTF';

//WordApp.Documents.SaveToFile(outfile);
//WordApp.Documents.SaveAs(outfile);

WordApp.Quit;
// i:=i+1;
end; //For
end;//if
  Mit Zitat antworten Zitat