+ Reply to Thread
Results 1 to 2 of 2

Printing leaves EXCEL.EXE process in Task Manager

  1. #1
    eeidfn
    Guest

    Printing leaves EXCEL.EXE process in Task Manager

    Hi,

    As you can see xlApp.Quit does not kill the process. I've tried in
    desperation in the last few lines to force the process to quit, which also
    does not work.

    As many times as I call printWithExcel, I get the same number of processes
    that are not exited, even the whole Delphi App exits.

    I have the following code in Delphi:
    procedure printWithExcel(fileName: String);
    var
    xlApp, workbook: Variant;
    ptrToXlApp, ptrToWorkbook: PVarData;
    begin
    WriteToLogFile('Output.printWithExcel() --->');
    if (fileName <> '') then
    begin
    xlApp := CreateOleObject('Excel.Application');
    xlApp.Visible := False;
    // Arguments to the Open function
    {
    function Open(const Filename: WideString; UpdateLinks: OleVariant;
    ReadOnly: OleVariant;
    Format: OleVariant; Password: OleVariant;
    WriteResPassword: OleVariant;
    IgnoreReadOnlyRecommended: OleVariant; Origin: OleVariant;
    Delimiter: OleVariant;
    Editable: OleVariant; Notify: OleVariant; Converter:
    OleVariant;
    AddToMru: OleVariant; lcid: Integer): ExcelWorkbook;
    safecall;
    }
    workbook := xlApp.Workbooks.Open(fileName, EmptyParam, True);
    workbook.Printout;
    workbook.Close(False);
    xlApp.Quit;
    ptrToWorkbook := FindVarData(workbook);
    ptrToWorkbook := nil;
    ptrToXlApp := FindVarData(xlApp);
    ptrToXlApp := nil;
    workbook := Unassigned;
    xlApp := Unassigned;
    end;
    WriteToLogFile('Output.printWithExcel() <---');
    end;


  2. #2
    exceluserforeman
    Guest

    RE: Printing leaves EXCEL.EXE process in Task Manager

    As you are writing in Delphi and this Discussion Group deals with Excel, I
    doubt you will get response.

    Perhaps you would be best to write a macro inside the workbook module that
    does the print job.

    Or include in your Delphi code to "Print to File" ...


    - -Mark

    "eeidfn" wrote:

    > Hi,
    >
    > As you can see xlApp.Quit does not kill the process. I've tried in
    > desperation in the last few lines to force the process to quit, which also
    > does not work.
    >
    > As many times as I call printWithExcel, I get the same number of processes
    > that are not exited, even the whole Delphi App exits.
    >
    > I have the following code in Delphi:
    > procedure printWithExcel(fileName: String);
    > var
    > xlApp, workbook: Variant;
    > ptrToXlApp, ptrToWorkbook: PVarData;
    > begin
    > WriteToLogFile('Output.printWithExcel() --->');
    > if (fileName <> '') then
    > begin
    > xlApp := CreateOleObject('Excel.Application');
    > xlApp.Visible := False;
    > // Arguments to the Open function
    > {
    > function Open(const Filename: WideString; UpdateLinks: OleVariant;
    > ReadOnly: OleVariant;
    > Format: OleVariant; Password: OleVariant;
    > WriteResPassword: OleVariant;
    > IgnoreReadOnlyRecommended: OleVariant; Origin: OleVariant;
    > Delimiter: OleVariant;
    > Editable: OleVariant; Notify: OleVariant; Converter:
    > OleVariant;
    > AddToMru: OleVariant; lcid: Integer): ExcelWorkbook;
    > safecall;
    > }
    > workbook := xlApp.Workbooks.Open(fileName, EmptyParam, True);
    > workbook.Printout;
    > workbook.Close(False);
    > xlApp.Quit;
    > ptrToWorkbook := FindVarData(workbook);
    > ptrToWorkbook := nil;
    > ptrToXlApp := FindVarData(xlApp);
    > ptrToXlApp := nil;
    > workbook := Unassigned;
    > xlApp := Unassigned;
    > end;
    > WriteToLogFile('Output.printWithExcel() <---');
    > end;
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1