Wat's wrong with this code.. [message #192914] |
Thu, 14 September 2006 03:46 |
sameer_am2002
Messages: 129 Registered: September 2002
|
Senior Member |
|
|
Can anybody correct me in this code..
PROCEDURE PROC_OLE IS -- DECLARE THE OLE OBJECTS
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;
-- DECLARE HANDLES TO OLE ARGUMENT LISTS ARGS OLE2.LIST_TYPE;
BEGIN
-- START EXCEL AND MAKE IT VISIBLE
APPLICATION := OLE2.CREATE_OBJ ('EXCEL.APPLICATION');
OLE2.SET_PROPERTY (APPLICATION, 'VISIBLE', 'TRUE');
-- RETURN OBJECT HANDLE TO THE WORKBOOKS COLLECTION
WORKBOOKS := OLE2.GET_OBJ_PROPERTY (APPLICATION, 'WORKBOOKS');
-- ADD A NEW WORKBOOK OBJECT TO THE WORKBOOKS COLLECTION
WORKBOOK := OLE2.INVOKE_OBJ (WORKBOOKS, 'ADD');
-- RETURN OBJECT HANDLE TO THE WORKSHEETS COLLECTION FOR THE WORKBOOK
WORKSHEETS := OLE2.GET_OBJ_PROPERTY (WORKBOOK, 'WORKSHEETS');
-- ADD A NEW WORKSHEET TO THE WORKSHEETS COLLECTION
WORKSHEET := OLE2.INVOKE_OBJ (WORKSHEETS, 'ADD');
-- RETURN OBJECT HANDLE TO CELL A1 ON THE NEW WORKSHEET
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG (ARGS, 1);
OLE2.ADD_ARG (ARGS, 1);
CELL := OLE2.INVOKE_OBJ (WORKSHEET, 'CELL', ARGS); --Giving error at this line...Non-Oracle Exception..
OLE2.DESTROY_ARGLIST (ARGS);
-- SET THE CONTENTS OF THE CELL TO 'HELLO EXCEL!'
OLE2.SET_PROPERTY (CELL, 'VALUE', 'HELLO EXCEL!');
--RELEASE THE OLE OBJECTS
OLE2.RELEASE_OBJ (CELL);
OLE2.RELEASE_OBJ (WORKSHEET);
OLE2.RELEASE_OBJ (WORKSHEETS);
OLE2.RELEASE_OBJ (WORKBOOK);
OLE2.RELEASE_OBJ (WORKBOOKS);
OLE2.RELEASE_OBJ (APPLICATION);
exception
when no_data_found then
MESSAGE ('successfully completed ');
pause;
synchronize;
-- commit;
WHEN OTHERS THEN
MESSAGE (SQLERRM || '~' || SQLCODE);
END;
Upd-mod: Please format your code and ALWAYS place it in 'code' tags.
[Updated on: Thu, 14 September 2006 23:02] by Moderator Report message to a moderator
|
|
|
|
|