Thema: Delphi Open Dialog autoconnect

Einzelnen Beitrag anzeigen

SnakeSchitt

Registriert seit: 17. Feb 2010
15 Beiträge
 
#8

Re: Open Dialog autoconnect

  Alt 26. Mär 2010, 14:50
Wems hilft hier mal der Ganze Hammer an Quelltext:

Delphi-Quellcode:
procedure TNeuenbeitraganlegen.Button_beitrag_freistellungClick(
  Sender: TObject);
var FileName:OleVariant;
  vWhat, vBookmark:OleVariant;
  p1, p2, p3, t1, t2, t3, u1, u2, u3 : integer;
  s, titel, untertitel, titelneu1, titelneu2, untertitelneu1, untertitelneu2 : string;
begin
  if OpenDialog1.Execute then
    FileName := OpenDialog1.FileName
  else
    exit;

   // Titel auslesen
s := Edit_beitrag_anlegen_titel.text;

p1 := Pos('"',s); //Auslesen erste Position
p2 := PosEx('"', s, p1 + 1); //Auslesen zweite Position
p3 := length(s);

// nun wird der Text dazwischen gespeichert und an die Variable Titel übergeben
titel := Copy(s, (p1+1), (p2-2));
// Untertitel auslesen, und an Untertitel übergeben
untertitel := Copy(s, (p2+2), (p3));

// Länge des Titels auf zwei Zeilen teilen, sollte dieser Länger als 45 Zeichen sein
if length(titel) > 45 then
begin
t1 := 1;
t2 := PosEx(' ', titel, 40);
t3 := length(titel);

titelneu1 := Copy(titel, (t1), (t2));
titelneu2 := Copy(titel, (t2), (t3));
end
else
begin
titelneu1 := titel;
end;

// Länge des Untertitels auf zwei Zeilen teilen, sollte dieser Länger als 45 Zeichen sein
if length(untertitel) > 45 then
begin
u1 := 1;
u2 := PosEx(' ', untertitel, 40);
u3 := length(untertitel);

untertitelneu1 := Copy(untertitel, (u1), (u2));
untertitelneu2 := Copy(untertitel, (u2), (u3));
end
else
begin
untertitelneu1 := untertitel;
end;

  WordApplication1.Connect;
  WordApplication1.Documents.OpenOld(FileName, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam);
  WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
  WordApplication1.Visible := True;
    vWhat:=wdGoToBookmark;
  vBookmark:= 'VORNAME';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(ComboBox_beitrag_anlegen_vorname.text);
    vWhat:=wdGoToBookmark;
  vBookmark:= 'NACHNAME';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(ComboBox_beitrag_anlegen_nachname.text);
    vWhat:=wdGoToBookmark;
  vBookmark:= 'LAENGE';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(MaskEdit_beitrag_anlegen_dauer.text);
    vWhat:=wdGoToBookmark;
  vBookmark:= 'NR';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(Label_beitrag_anlegen_nummer.Caption);
    vWhat:=wdGoToBookmark;
  vBookmark:= 'TITEL1';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(titelneu1);
      vWhat:=wdGoToBookmark;
  vBookmark:= 'UNTERTITEL1';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(untertitelneu1);
    vWhat:=wdGoToBookmark;
  vBookmark:= 'TITEL2';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(titelneu2);
      vWhat:=wdGoToBookmark;
  vBookmark:= 'UNTERTITEL2';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(untertitelneu2);

  
end;
  Mit Zitat antworten Zitat