Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
eeidfn
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
exceluserforeman
 
Posts: n/a
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plotting Bands for Task Overlaps gtslabs Charts and Charting in Excel 1 December 5th 05 01:38 AM
force excel to run in only one process excel.exe Daniel Excel Worksheet Functions 0 July 8th 05 04:42 AM
Task Manager and Excel 2003 Mike Excel Discussion (Misc queries) 1 April 20th 05 10:40 PM
loop trough e-mail address list to send task lists with outlook Paul. Excel Discussion (Misc queries) 2 April 14th 05 11:48 AM
Sumif Linking to Another Workbook error #VALUE! Tunde Excel Discussion (Misc queries) 16 March 4th 05 03:02 AM


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"