How to kill a process (excel.exe) from forms 6i [message #87713] |
Thu, 03 February 2005 03:18 |
Rohit
Messages: 43 Registered: January 2002
|
Member |
|
|
I am using forms 6i with oracle 8i.
I have created a procedure which writes to an excel file. And reads from an excel file too.
Now the problem is that the process excel.exe runs in memory even after closing down the application.
I have terminated the application like
/*
args := ole2.create_arglist;
ole2.add_arg(args, 'SAVEAS');
ole2.invoke(Workbooks, args);
ole2.destroy_arglist(args);
args := ole2.create_arglist;
ole2.add_arg(args, 'QUIT');
ole2.invoke(application, args);
ole2.destroy_arglist(args);
ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.release_obj(application);
*/
Please help me in terminating the excel.exe process.
Thanks in advance.
Rohit
|
|
|
|
Re: How to kill a process (excel.exe) from forms 6i [message #87738 is a reply to message #87713] |
Sun, 06 February 2005 15:26 |
Raj Nandipati
Messages: 3 Registered: February 2005
|
Junior Member |
|
|
Hi Rohit ... After SAVE AS statement, Try this one ...
-- Close the document
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 2);
OLE2.INVOKE(workbooks, 'Close', args);
OLE2.DESTROY_ARGLIST(args);
-- Release handles
OLE2.SET_PROPERTY(application, 'Visible', 'False');
OLE2.INVOKE(application, 'Quit');
OLE2.RELEASE_OBJ(worksheet);
OLE2.RELEASE_OBJ(worksheets);
OLE2.RELEASE_OBJ(workbook);
OLE2.RELEASE_OBJ(workbooks);
OLE2.RELEASE_OBJ(application);
|
|
|
Re: How to kill a process (excel.exe) from forms 6i [message #87743 is a reply to message #87738] |
Sun, 06 February 2005 21:30 |
Rohit
Messages: 43 Registered: January 2002
|
Member |
|
|
Thank you, Raj Nandipati for your reply.
I have used it in my code. But it is not killing the excel.exe process running in the background. Please try and help me in any other way if possible by giving some other code.
Here is the code that I am using for writing into the excel file.
declare
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
args ole2.list_type;
row number:=1;
col number:=1;
cursor Vcursor is select empno from scott.emp;
i Vcursor%rowtype;
cell_value varchar2(2000);
BEGIN
application := ole2.create_obj('Excel.Application');
ole2.set_property(application, 'Visible', 'False');
workbooks := ole2.get_obj_property(application, 'Workbooks');
workbook := ole2.get_obj_property(workbooks, 'Add');
worksheets := ole2.get_obj_property(workbook, 'Worksheets');
worksheet := ole2.get_obj_property(worksheets, 'Add');
for i in Vcursor -- Open Cursor, that returns "value" value
loop
args := ole2.create_arglist;
ole2.add_arg(args, row);
ole2.add_arg(args, col);
cell := ole2.get_obj_property(worksheet, 'Cells', args);
ole2.destroy_arglist(args);
ole2.set_property(cell, 'Value', i.empno);
row := row+1;
--col := col+1;
end loop; -- Close cursor
args := ole2.create_arglist;
ole2.add_arg(args, 'c:EXAMPLE.XLS');
ole2.invoke(workbook, 'SaveAs', args);
ole2.destroy_arglist(args);
-- Close the document
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 2);
OLE2.INVOKE(workbooks, 'Close', args);
OLE2.DESTROY_ARGLIST(args);
-- Release handles
OLE2.SET_PROPERTY(application, 'Visible', 'False');
ole2.invoke(application, 'Close');
ole2.invoke(application, 'Quit');
ole2.release_obj(cell);
ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.release_obj(application);
END;
Rohit
|
|
|