Autor Beitrag
lexmy3
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Do 02.02.06 16:04 
Hallo allesamt,

Ich habe vor per Auswahl in der Radiogroup Textmarken in Word anzusprechen, jedoch habe ich ein Problemm, denn je öffter ich die Radiobuttons betätige , desto mehr einträge kommen ins Word. Also diese vermehren sich mit jedem klick. :gruebel:

Also irgend was mache ich falsch, kann mir hier einer aushelfen.

So hatte ich es bis jetzt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
/////////////////////////////RadioButtons///////////////////////////////////
begin
  if Form1.RadioGroup1.Items[Form1.RadioGroup1.ItemIndex] = 'ppa.' then
TextmarkenName:= 'RB1';   //TextMarke
if WordDocument1.Bookmarks.Exists (TextmarkenName) then
begin
vWhat:=WordDocument1.Bookmarks.Item(TextmarkenName).Range;
vWhat.InsertAfter ('ppa.');
vWhat.Font.Color := clBlue;
end;

  if Form1.RadioGroup1.Items[Form1.RadioGroup1.ItemIndex] = 'i.V.' then
TextmarkenName:= 'RB1';   //TextMarke
if WordDocument1.Bookmarks.Exists (TextmarkenName) then
begin
vWhat:=WordDocument1.Bookmarks.Item(TextmarkenName).Range;
vWhat.InsertAfter ('i.V.');
vWhat.Font.Color := clBlue;
end;

   if Form1.RadioGroup1.Items[Form1.RadioGroup1.ItemIndex] = 'i.A.' then
TextmarkenName:= 'RB1';   //TextMarke
if WordDocument1.Bookmarks.Exists (TextmarkenName) then
begin
vWhat:=WordDocument1.Bookmarks.Item(TextmarkenName).Range;
vWhat.InsertAfter ('i.A.');
vWhat.Font.Color := clBlue;
end;
    end;


mfg

lexmy3
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Do 02.02.06 20:14 
Hallo

erstmal zum reinen Ablauf: warum machst du dir es sooo kompliziert?
In den Radiobuttonitems steht doch schon alles. das zB. 'ppa.' hast du mind. 3x im code (2xin der If-abfrage und noch 1x im radioitem selbst). und die 3 einzelnen codeblöcke gehen auch in einem einzigen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
TextmarkenName:= 'RB1';   //TextMarke  
if RadioGroup1.ItemIndex<>-1 then
 if WordDocument1.Bookmarks.Exists (TextmarkenName) then  
  begin  
    vWhat:=WordDocument1.Bookmarks.Item(TextmarkenName).Range;  
    vWhat.InsertAfter (RadioGroup1.Items[RadioGroup1.ItemIndex]);  
    vWhat.Font.Color := clBlue;  
  end;

Damit arbeitest du mit den Einträgen innerhalb der Radiogroup, mit einer Änderung dort läuft auch diese proc automatisch, ohne eine Änderung.

zum Fehler: Du fügst mit inserafter immer wieder den Text hinzu, bei jedem Klick. Abhilfe schafft ein Formfield (www.dsdt.info/tipps/?id=599), das gibt es nur einmal und du füllst den direkt den Text des Formfields. Alternativ: laß das mit dem insertafter, schreib den Text mit typeparagraph rein. Dann wird die Textmarke überschrieben und du findest sie nicht mehr. Nachteil: ein weiterer klick in der Radiogroup und es erfolgt keine Änderung mehr, da die Textmarke nicht merh existiert.
Das Formfield ist für sich sicher besser geeignet.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)