Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   ISAP -> DOC to PDF -> CreateOleObject('Word.Application') funktioniert nicht (https://www.delphipraxis.net/214991-isap-doc-pdf-createoleobject-word-application-funktioniert-nicht.html)

erich.wanker 18. Apr 2024 13:45

ISAP -> DOC to PDF -> CreateOleObject('Word.Application') funktioniert nicht
 
Hallo,
meine ISAP Anwendung (um ein bestehendes Word-DOC in ein PDF umzuwandeln) funktioniert nicht.
Ich vermute - es hängt damit zusammen dass die ISAPI vom Apache mit "Loakes System" ausgeführt wird?
Wenn ja - wie kann ich ein "CreateOleObject As Admin" oder so ähnlich ausführen? -- oder irgedwie anders ein Word-Doc in ein PDF konverteiren?
Den Apach Dienst am Server darf ich nicht als anderen User ausführen

Danke für Hinweise
Erich

Hier mein Code:

Uses Comobj, Varianst
Vars: WordAllication und WordFile : OLEVariant;

Code:
          WordApplication := Null;
          WordFile := Null;

          try
            // create Word OLE
            try
              // Check if Word is already opened?
              WordApplication := GetActiveOleObject('Word.Application' );
            except
              try
                WordApplication := CreateOleObject('Word.Application' );
                WordApplication.Visible := true;
              except
                Exception.Create( 'Error' );
              end;
            end;

          except
            WordApplication := Null;
          end;

          If VarIsNull( WordApplication ) = False
          then
          begin
            try
              WordApplication.Visible := true; // set to False if you do not want to see the activity in the background
              WordApplication.DisplayAlerts := true; // ensures message dialogs do not interrupt the flow of your automation process. May be helpful to set to True during testing and debugging.

              // Open Word File
              try
                WordFile := WordApplication.Documents.Open(merge_dateiname_mit_pfad );
              except
                WordFile := Null;
              end;

              If VarIsNull( WordFile ) = False
              then
              begin
                WordFile.SaveAs2( merge_destfolder + '\aenderung' + UniMainModule.Z_AENDERUNG.FieldByName( 'Reportnummer' ).AsString + '\converted.pdf', 17 ); // wdFormatPDF = 17
              end
              else
              begin
                showtoast('Word-Dokument konnte nicht konvertiert werden');
              end;
            finally
              WordFile.Close;
              WordApplication.DisplayAlerts := true;
              WordApplication.Quit;
              WordFile := Unassigned;
              WordApplication := Unassigned;
            end;
          end
          else
          begin
            showtoast('Word konnte nicht gestartet werden');
          end;

himitsu 18. Apr 2024 14:07

AW: ISAP -> DOC to PDF -> CreateOleObject('Word.Application') funktioniert nicht
 
Es gibt ganz bestimmt auch Konvertierungsprogramme von irgendwelchen anderen Herstellern.
Bei Google suchenword to pdf

Du könntest versuchen die Registrierung in die Registry dieses System-Nutzers zu kopieren, bzw. das COM-/ActiveX-Control manuell aufzurufen (DLL selbst laden usw.)
oder das Konvertieren mit einem zweiten Service/Programm in einem anderen Nutzerkontext ausführen und z.B. via IPC miteinander reden, bzw. CreateProcessAsUser oder Dergleichen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz