Home » Developer & Programmer » Forms » open excel application from forms
open excel application from forms [message #318281] Tue, 06 May 2008 06:17 Go to next message
smithagirish
Messages: 10
Registered: March 2008
Location: kochi
Junior Member
How can i open a new Excel application from Forms 10g?
Re: open excel application from forms [message #318294 is a reply to message #318281] Tue, 06 May 2008 07:12 Go to previous messageGo to next message
Kaeluan
Messages: 179
Registered: May 2005
Location: Montreal, Quebec
Senior Member
Here are some command that can help you, but you need to have Webutil library installed to use them. I don`t know what you want to do, but maybe you don`t need all those variables in my code if you don`t need to keep handle on your excel file but you may need them if you want to put data in the excel file from forms 10g


  -- Variables
  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;   
  args          CLIENT_OLE2.LIST_TYPE;
  obj_hnd       CLIENT_OLE2.OBJ_TYPE; 
  tab1          client_OLE2.OBJ_TYPE;
  tab2          client_OLE2.OBJ_TYPE;
  tab3          client_OLE2.OBJ_TYPE;

  -- Open Excel
  application := CLIENT_OLE2.CREATE_OBJ('Excel.Application');
  workbooks := CLIENT_OLE2.GET_OBJ_PROPERTY(application,'Workbooks');
  args := CLIENT_OLE2.CREATE_ARGLIST;
  CLIENT_OLE2.ADD_ARG(args,'c:\file.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');

  -- Give you handle on different tab in your Excel file
  tab1 := get_object_handle(1);
  tab2 := get_object_handle(2);
  tab3 := get_object_handle(3);

FUNCTION get_object_handle(tpage NUMBER) RETURN OLE2.OBJ_TYPE IS
    worksheet2  CLIENT_OLE2.OBJ_TYPE;

BEGIN
    args := client_OLE2.CREATE_ARGLIST;
    client_OLE2.ADD_ARG(args, tpage);
    worksheet2 := CLIENT_OLE2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);
    client_OLE2.DESTROY_ARGLIST(args);
    client_ole2.INVOKE(worksheet2,'Activate');
    client_OLE2.RELEASE_OBJ(worksheet2);

    return CLIENT_OLE2.GET_OBJ_PROPERTY(application,'activesheet');
END;



  -- Invoke Save As
  args:=client_OLE2.CREATE_ARGLIST;
  client_ole2.ADD_ARG(args,'c:\test2.xls');
  CLIENT_OLE2.INVOKE(workbook, 'SaveAs',args);


  -- Exit Excel and release object
   client_OLE2.INVOKE(workbook, 'Close');
   client_OLE2.INVOKE(application, 'Quit');

   client_OLE2.RELEASE_OBJ(worksheet);
   client_OLE2.RELEASE_OBJ(worksheets);
   client_ole2.release_obj(tab1);
   client_ole2.release_obj(tab2);
   client_ole2.release_obj(tab3);
   client_OLE2.RELEASE_OBJ(workbook);
   client_OLE2.RELEASE_OBJ(workbooks);
   client_OLE2.RELEASE_OBJ(application);

[Updated on: Tue, 06 May 2008 12:20]

Report message to a moderator

Re: open excel application from forms [message #550573 is a reply to message #318294] Tue, 10 April 2012 08:48 Go to previous message
alancounihan
Messages: 1
Registered: April 2012
Location: Cork
Junior Member
I've added the code for the open excel and it all compiled lovely.

However when its openeing the excel file, it locks it rather than opening it in a new window. What do i do to overcome this?
Previous Topic: Dynamic Query
Next Topic: 11g OLE2 Excel printing behind parameter form.
Goto Forum:
  


Current Time: Thu Dec 08 04:21:57 CST 2016

Total time taken to generate the page: 0.08898 seconds