Einzelnen Beitrag anzeigen

Frulle

Registriert seit: 23. Dez 2004
6 Beiträge
 
Delphi 7 Professional
 
#1

Problem mit OLE Zugriff auf Word

  Alt 1. Sep 2005, 21:47
Hallo,

Ich habe folgendes Problem und hoffe, das ich hier Hilfe finden kann.
Ich greife von Delphi aus über die WordApplication Komponente auf Word zu. Hier der entsprechende Quellcode:

Delphi-Quellcode:
WordApplication1.Connect;
try
WordApplication1.Documents.Open(Filename, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
Filetyp := wdFormatHTML; // doc --> html
Outfile:= word_file_out; // Speicherpfad
WordDocument1.SaveAs(Outfile,Filetyp); // Speichert die Datei als html-Datei ab
WordDocument1.Close;
WordDocument1.Disconnect;
finally
WordApplication1.Quit;
WordApplication1.Disconnect;
end;
Das Problem ist nun, dass dieser Zugriff mal funktioniert und mal nicht, und (in meinen Augen) komplett zufallsabhängig. Mal kann ich den Codeschnippsel 10 mal nacheinander aufrufen, danach gibt er mir jedes zweite Mal einen Fehler aus.

Die Fehlermeldungen wechseln sich dabei ab (auch wenn ich das ganze Programm vorher resette, die Prozedur also nicht schon lief):

Zitat:
Der RPC-Server ist nicht verfügbar.
Zitat:
Exception EOleException in Modul Project1.exe bei 000B7E8B.
Der RPC-Server ist nicht verfügbar.
Zitat:
Der Remoteprozeduraufruf ist fehlgeschlagen.
Word selbst ist standartmäßig deaktiviert. Ich habe schon diverse Versuche unternommen, aber es bleibt ein Glücksspiel - mal startet er, mal nicht.
Hat jemand eine Idee woran das liegen könnte und wie ich das verhindern kann?
  Mit Zitat antworten Zitat