|
Re: open excel application from forms [message #318294 is a reply to message #318281] |
Tue, 06 May 2008 07:12 |
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
|
|
|
|