Re: REad an excel cell using oracle forms

From: SoulSurvivor <markyg_7_at_yahoo.co.uk>
Date: 17 Mar 2003 06:25:27 -0800
Message-ID: <8d9c6fd.0303170625.4b09908f_at_posting.google.com>


You have to open up all the objects in the correct order. Try opening WorkBook before WorkSheets.
Also, worksheets is a property of Workbook, not Workbooks.

Hierarchy as follows:

APPLICATION
  WORKBOOKS
    WORKBOOK

      WORKSHEETS
        WORKSHEET

Try rewriting you code to

application:= ole2.create_obj('Excel.Application'); workbooks := ole2.GET_OBJ_PROPERTY(application, 'Workbooks');

  • Open the required workbook args:= ole2.create_arglist; ole2.add_arg(args, 'C:\test.xls'); workbook := ole2.GET_OBJ_PROPERTY (workbooks, 'Open', args); ole2.destroy_arglist(args);

worksheets := ole2.invoke_OBJ(workbook, 'Worksheets');

.. 
..
..

See examples on Metalink for more info.

M

Manikandan <member12054_at_dbforums.com> wrote in message news:<2650961.1047880057_at_dbforums.com>...
> Hi,
> I have the follwoing code to read an excel cell from oracle forms.But
> i am getting the error 'ora-305522' during the excution of the line
>
> worksheets := ole2.invoke_OBJ(workbooks, 'Worksheets');
>
> But i tried with
> worksheets := ole2.GET_OBJ_PROPERTY(workbooks, 'Worksheets');
>
> but of no use...still getting the same error...any one there to help me
> out??? Is there any way to modify the code???
>
> Here is my code:
>
> DECLARE
>
> -- Declare handles to OLE objects
> application ole2.obj_type;
> workbooks ole2.obj_type;
> workbook ole2.obj_type;
> worksheet ole2.obj_type;
> worksheets ole2.obj_type;
> cell ole2.obj_type;
>
> -- Declare handles to OLE argument lists
> args ole2.list_type;
> check_file text_io.file_type;
> no_file exception;
> PRAGMA EXCEPTION_INIT (no_file, -302000);
> cell_value varchar2(2000);
>
> BEGIN
>
> -- Check the file can be found, if not exception no_file will be raised
> check_file := TEXT_IO.FOPEN('C:\test.xls','R');
> TEXT_IO.FCLOSE(check_file);
>
> application:= ole2.create_obj('Excel.Application');
> workbooks := ole2.GET_OBJ_PROPERTY(application, 'Workbooks');
> worksheets := ole2.invoke_OBJ(workbooks, 'Worksheets');
>
> -- Open the required workbook
> args:= ole2.create_arglist;
> ole2.add_arg(args, 'C:\test.xls');
> workbook := ole2.GET_OBJ_PROPERTY (workbooks, 'Open', args);
> ole2.destroy_arglist(args);
>
> -- Open worksheet Sheet1 of that Workbook
> args:= ole2.create_arglist;
> ole2.add_arg(args, 'Sheet1');
> worksheet := ole2.GET_OBJ_PROPERTY (worksheets, 'Worksheets', args);
> ole2.destroy_arglist(args);
>
> -- Get value of cell A1 of worksheet Sheet1
> args:= ole2.create_arglist;
> ole2.add_arg(args, 1);
> ole2.add_arg(args, 1);
> cell:= ole2.GET_OBJ_PROPERTY (worksheet, 'Cells', args);
> ole2.destroy_arglist(args);
> cell_value :=ole2.get_char_property(cell, 'Value');
> message(cell_value);
>
> ole2.invoke(application,'Quit');
>
> -- Release the OLE2 object handles
> ole2.release_obj(application);
> ole2.release_obj(workbooks);
> ole2.release_obj(workbook);
> ole2.release_obj(worksheets);
> ole2.release_obj(cell);
>
> EXCEPTION
> WHEN no_file THEN
> MESSAGE('File not found.');
>
> END;
Received on Mon Mar 17 2003 - 15:25:27 CET

Original text of this message