Home » Developer & Programmer » Forms » client_ole2.create_obj('Excel.Application) not working
client_ole2.create_obj('Excel.Application) not working [message #470518] Tue, 10 August 2010 03:04 Go to next message
samimerchant
Messages: 3
Registered: July 2010
Junior Member
Hi i have problem with client_ole2.creatobj('Excel.Application") but i m not getting any error. i put messages but apter the above code form seems to be hanged...

please help me....

---- code ------ as follows ------

DECLARE


-- Declare handles to OLE objects
application CLIENT_OLE2.OBJ_TYPE;
workbooks CLIENT_OLE2.OBJ_TYPE;
workbook CLIENT_OLE2.OBJ_TYPE;
worksheets CLIENT_OLE2.OBJ_TYPE;
worksheet CLIENT_OLE2.OBJ_TYPE;
cell CLIENT_OLE2.OBJ_TYPE;

args CLIENT_OLE2.OBJ_TYPE;


Check_file CLIENT_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 := CLIENT_TEXT_IO.FOPEN('C:\test.XLS','W');
CLIENT_TEXT_IO.FCLOSE(Check_file);
Message('hellllllllllooo');



-- ***********************************

application := CLIENT_OLE2.CREATE_OBJ('Excel.Application');
--CLIENT_OLE2.set_property(application,'Visible','true');
workbooks := CLIENT_OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.add_arg(args,'c:\test.xls');
workbook := CLIENT_OLE2.GET_OBJ_PROPERTY(workbooks,'Open',args);
CLIENT_OLE2.destroy_arglist(args);
worksheets := CLIENT_OLE2.GET_OBJ_PROPERTY(workbook, 'Worksheets');


worksheet := CLIENT_OLE2.GET_OBJ_PROPERTY(application,'activesheet');
CLIENT_OLE2.SET_PROPERTY(worksheet , 'Value','Sheet1');

-- ***********************************


-- PASS VALUE INTO Excel CELL (ROW 371, COL 3)
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(args, 371);
CLIENT_OLE2.ADD_ARG(args, 3);
cell := CLIENT_OLE2.GET_OBJ_PROPERTY(worksheet,'Cells', args);
CLIENT_OLE2.DESTROY_ARGLIST(args);
CLIENT_OLE2.SET_PROPERTY(cell, 'Value', '97FI01');

-- Get value of cell (372,3) of worksheet Sheet1
args:= CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args, 372);
CLIENT_OLE2.add_arg(args, 3);
cell:= CLIENT_OLE2.get_obj_property(worksheet, 'Cells', args);
CLIENT_OLE2.destroy_arglist(args);
cell_value :=CLIENT_OLE2.get_char_property(cell, 'Value');
message(cell_value);



-- save document as test.xls

CLIENT_OLE2.INVOKE(worksheet, 'Save');
CLIENT_OLE2.INVOKE(workbook, 'Save');
CLIENT_OLE2.INVOKE(workbook,'CLOSE');

-- Release the CLIENT_OLE2 object handles
CLIENT_OLE2.release_obj(cell);
CLIENT_OLE2.release_obj(worksheet);
CLIENT_OLE2.release_obj(worksheets);
CLIENT_OLE2.release_obj(workbook);
CLIENT_OLE2.release_obj(workbooks);

CLIENT_OLE2.invoke(application,'Quit');
CLIENT_OLE2.release_obj(application);

-- ASSIGN RETURN VALUE FROM EXCEL TO Text Field
:block3.param_desc := cell_value;


exception
WHEN no_file THEN
MESSAGE('file not found.');
WHEN OTHERS THEN
MESSAGE(sqlerrm);
PAUSE;
FOR i IN 1 .. tool_err.nerrors LOOP
MESSAGE(tool_err.message);
PAUSE;
tool_err.pop;
END LOOP;


END;
Re: client_ole2.create_obj('Excel.Application) not working [message #470827 is a reply to message #470518] Wed, 11 August 2010 01:17 Go to previous messageGo to next message
sasipalarivattom
Messages: 121
Registered: June 2007
Location: Cochin ( INDIA )
Senior Member
Please post your codes in code tag.
Its more readable and attractive.

Then search this forum with excel or ole2 , there are lots of threads on this subject.

Regards,
Sasi


---- code ------ as follows ------

DECLARE 
    -- Declare handles to OLE objects  
    application client_ole2.obj_type; 
    workbooks   client_ole2.obj_type; 
    workbook    client_ole2.obj_type; 
    worksheets  client_ole2.obj_type; 
    worksheet   client_ole2.obj_type; 
    cell        client_ole2.obj_type; 
    args        client_ole2.obj_type; 
    check_file  client_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 := client_text_io.Fopen('C:\test.XLS', 'W'); 
    client_text_io.Fclose(check_file); 
    Message('hellllllllllooo'); 

    -- *********************************** 
    application := client_ole2.Create_obj('Excel.Application'); 

    --CLIENT_OLE2.set_property(application,'Visible','true');  
    workbooks := client_ole2.Get_obj_property(application, 'Workbooks'); 
    args := client_ole2.create_arglist; 
    client_ole2.Add_arg(args, 'c:\test.xls'); 

    workbook := client_ole2.Get_obj_property(workbooks, 'Open', args); 
    client_ole2.Destroy_arglist(args); 

    worksheets := client_ole2.Get_obj_property(workbook, 'Worksheets'); 
    worksheet := client_ole2.Get_obj_property(application, 'activesheet'); 
    client_ole2.Set_property(worksheet, 'Value', 'Sheet1'); 

    -- *********************************** 
    -- PASS VALUE INTO Excel CELL (ROW 371, COL 3) 
    args := client_ole2.create_arglist; 
    client_ole2.Add_arg(args, 371); 
    client_ole2.Add_arg(args, 3); 

    cell := client_ole2.Get_obj_property(worksheet, 'Cells', args); 
    client_ole2.Destroy_arglist(args); 
    client_ole2.Set_property(cell, 'Value', '97FI01'); 

    -- Get value of cell (372,3) of worksheet Sheet1  
    args := client_ole2.create_arglist; 
    client_ole2.Add_arg(args, 372); 
    client_ole2.Add_arg(args, 3); 

    cell := client_ole2.Get_obj_property(worksheet, 'Cells', args); 
    client_ole2.Destroy_arglist(args); 
    cell_value := client_ole2.Get_char_property(cell, 'Value'); 

    Message(cell_value); 
    -- save document as test.xls 
    client_ole2.Invoke(worksheet, 'Save'); 
    client_ole2.Invoke(workbook, 'Save'); 
    client_ole2.Invoke(workbook, 'CLOSE'); 

    -- Release the CLIENT_OLE2 object handles  
    client_ole2.Release_obj(cell); 
    client_ole2.Release_obj(worksheet); 
    client_ole2.Release_obj(worksheets); 
    client_ole2.Release_obj(workbook); 
    client_ole2.Release_obj(workbooks); 

    client_ole2.Invoke(application, 'Quit'); 
    client_ole2.Release_obj(application); 
    -- ASSIGN RETURN VALUE FROM EXCEL TO Text Field 
    :block3.param_desc := cell_value; 
EXCEPTION 
    WHEN no_file THEN 
      Message('file not found.'); 
    WHEN OTHERS THEN 
      Message(sqlerrm); 
      PAUSE; 

      FOR i IN 1 .. tool_err.nerrors LOOP 
          Message(tool_err.message); 
          PAUSE; 

          tool_err.pop; 
      END LOOP; 
END;  

Re: client_ole2.create_obj('Excel.Application) not working [message #471015 is a reply to message #470827] Thu, 12 August 2010 00:17 Go to previous messageGo to next message
ganesh_jadhav0509
Messages: 74
Registered: May 2007
Location: Chester
Member

Had you configured webutil?

If not then that may be the issue..
Re: client_ole2.create_obj('Excel.Application) not working [message #471060 is a reply to message #471015] Thu, 12 August 2010 02:16 Go to previous message
samimerchant
Messages: 3
Registered: July 2010
Junior Member
thanks for reply.....
Yes i have configured the webutil and already "client_host" command is working properly....
Previous Topic: How to us ALTER TABLE in forms
Next Topic: Unable to create excel object for Excel 2007/Windows 7
Goto Forum:
  


Current Time: Fri Sep 20 03:37:56 CDT 2024