‎2006 Jun 13 8:37 AM
Hi Friends,
I want to ask a logic of OLE2 and Excel. Now, I write this code;
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 0.
CALL METHOD OF application 'Workbooks' = workbooks.
CALL METHOD OF workbooks 'Add' = workbook.
call method of workbook 'SAVEAS' exporting #1 = p_fname #2 = -4543.
the second parameter of 'SAVEAS' method is passing as -4543. I have looked that the enum number of Excel.XlFileFormat.xlWorkbookNormal using VB Macro Editor is equal to -4543. But when I write -4543 this code is not run. Another person is passing #2 = 1.
How does do? Is there another number declaration of enums for Excel OLE2 objects?
Thanks.
‎2006 Jun 13 8:54 AM
Hi,
check this sample...
REPORT ZTEST_OLE .
INCLUDE ole2incl.
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
DATA: BEGIN OF itab1 OCCURS 0,
first_name(10),
last_name(10),
END OF itab1.
START-OF-SELECTION.
itab1-first_name = '123445'.
itab1-last_name = 'tesst'.
append itab1.
clear itab1.
itab1-first_name = '123446'.
itab1-last_name = 'tesst'.
append itab1.
clear itab1.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 1.
CALL METHOD OF application 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
* Create first Excel Sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 1.
CALL METHOD OF sheet 'Activate'.
SET PROPERTY OF sheet 'Name' = 'Sheet1'.
LOOP AT itab1.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Value' = itab1-first_name.
index = index + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Value' = itab1-last_name.
ENDLOOP.
* Save excel speadsheet to particular filename
<b> CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'c:tempexceldoc1.xls' "filename
#2 = 1. "fileFormat</b>
Regards
vijay
‎2006 Jun 13 8:54 AM
Hi Nail,
1.
Have a look at the programs .
These are dealt with OLE and EXCEL.
<b>RSOLETT1
RSDEMO01</b>
I believe that those solve ur problem
<b>Thanks,
Venkat.O</b>
‎2006 Jun 13 9:15 AM
Thanks for your answers.
But I could not get the real answer. I want to know, why Format is equalt to 1? And when I look in VB Macro Editor there is no format equal to 1. If 1 equal to Excel.XlFileFormat.xlWorkbookNormal, in VB Macro Excel.XlFileFormat.xlWorkbookNormal is equalt to -4543. But if I pass -4543, there is nothing. Who defines or where defined to pass 1? How?
Thanks.