Einzelnen Beitrag anzeigen

Newcomer91

Registriert seit: 9. Mär 2010
66 Beiträge
 
Delphi 2010 Professional
 
#1

txt zu doc konvertieren

  Alt 11. Feb 2011, 11:28
Morgen,

zurzeit arbeite ich an einem älteren Projekt weiter,
und bin nun an einem Punkt angekommen, wo mir Delphi Hilfe und Co
nichtmehr helfen kann.

Ich habe eine bestehende Textdatei welche ich mit klick auf einem
Button öffne - allerdings als .doc Datei!

Ich habe zwar Code finden können, mit welchem man doc in txt wandeln kann,
als ich dann allerdings versuchte, es umzuändern, funktionierte es nichtmehr.
Hier der Quellcode:

Delphi-Quellcode:
procedure TForm1.DOC2Text(InFile, OutFile: OleVariant);
var Filetyp: OleVariant;
begin
  WordApplication1.Connect;
  try
    // Hiermit wird das Word Formular sichtbar (nützlich für Debugging :)
    //WordApplication1.Visible := True;
    WordApplication1.Documents.Open(InFile, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
    EmptyParam);
    WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
    Filetyp := wdFormatText;
    WordDocument1.SaveAs(OutFile,Filetyp);
    WordDocument1.Close;
    WordDocument1.Disconnect;
  finally
    WordApplication1.Disconnect;
    WordApplication1.Quit;
  end;
end;
Danke im Vorraus
  Mit Zitat antworten Zitat