‎2007 Mar 19 11:49 AM
hi all!
I need know, what method or property i have to use, for set up the filename by default, for the workbook that i created.
thank in advance
‎2007 Mar 19 12:24 PM
You assign the file name when you save the file.
For example......
data: e_sheet type ole2_object.
data: e_appl type ole2_object.
data: e_work type ole2_object.
data: e_cell type ole2_object.
data: e_wbooklist type ole2_object.
parameters: p_file type localfile default 'C:Test.xls'.
start-of-selection.
* Start the application
create object e_appl 'EXCEL.APPLICATION'.
set property of e_appl 'VISIBLE' = 0.
* Open the file
call method of e_appl 'WORKBOOKS' = e_wbooklist.
get property of e_wbooklist 'Application' = e_appl .
set property of e_appl 'SheetsInNewWorkbook' = 1 .
call method of e_wbooklist 'Add' = e_work .
get property of e_appl 'ActiveSheet' = e_sheet .
set property of e_sheet 'Name' = 'Test' .
* Position to specific cell in Column 1
call method of e_appl 'Cells' = e_cell
exporting
#1 = 1
#2 = 1.
* Set the value
set property of e_cell 'Value' = 'ABC'.
** Close the file
get property of e_appl 'ActiveWorkbook' = e_work.
call method of e_work 'SAVEAS'
exporting
#1 = p_file
#2 = 1 . " Don't ask me when closing
call method of e_work 'close'.Regards,
Rich Heilman
‎2007 Mar 19 12:24 PM
You assign the file name when you save the file.
For example......
data: e_sheet type ole2_object.
data: e_appl type ole2_object.
data: e_work type ole2_object.
data: e_cell type ole2_object.
data: e_wbooklist type ole2_object.
parameters: p_file type localfile default 'C:Test.xls'.
start-of-selection.
* Start the application
create object e_appl 'EXCEL.APPLICATION'.
set property of e_appl 'VISIBLE' = 0.
* Open the file
call method of e_appl 'WORKBOOKS' = e_wbooklist.
get property of e_wbooklist 'Application' = e_appl .
set property of e_appl 'SheetsInNewWorkbook' = 1 .
call method of e_wbooklist 'Add' = e_work .
get property of e_appl 'ActiveSheet' = e_sheet .
set property of e_sheet 'Name' = 'Test' .
* Position to specific cell in Column 1
call method of e_appl 'Cells' = e_cell
exporting
#1 = 1
#2 = 1.
* Set the value
set property of e_cell 'Value' = 'ABC'.
** Close the file
get property of e_appl 'ActiveWorkbook' = e_work.
call method of e_work 'SAVEAS'
exporting
#1 = p_file
#2 = 1 . " Don't ask me when closing
call method of e_work 'close'.Regards,
Rich Heilman
‎2007 Mar 19 12:25 PM
try this
DATA: o_application TYPE ole2_object,
o_workbook TYPE ole2_object,
o_worksheet TYPE ole2_object,
o_sheet TYPE ole2_object.
PARAMETERS: p_excel TYPE rlgrap-filename DEFAULT 'C:\Soft\Book1.xls',
p_sheet(30) TYPE c DEFAULT 'Sheet2'.
START-OF-SELECTION.
CREATE OBJECT o_application 'Excel.Application'.
CALL METHOD OF o_application 'Workbooks' = o_workbook.
CALL METHOD OF o_workbook 'Open' EXPORTING #1 = p_excel.
CALL METHOD OF o_application 'WORKSHEETS' = o_sheet EXPORTING #1 = p_sheet.
CALL METHOD OF o_sheet 'DELETE'.
CALL METHOD OF o_workbook 'Save'.
CALL METHOD OF o_application 'Save'.
FREE OBJECT: o_application, o_workbook, o_worksheet, o_sheet.
Please reward if useful.
‎2007 Mar 19 1:21 PM
thanks very much
The answers have been help full for me.
best regards