Skip to Content
0
Former Member
May 29, 2008 at 09:49 PM

Excel OLE Print

344 Views

Hi,

I am using the following code to print the excel sheet.

  • handles for OLE objects

DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object

H_MAPL TYPE OLE2_OBJECT, " list of workbooks

H_MAP TYPE OLE2_OBJECT, " workbook

H_ZL TYPE OLE2_OBJECT, " cell

H_F TYPE OLE2_OBJECT, " font

H_ACT TYPE OLE2_OBJECT.

BREAK SMATTA.

CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.

SET PROPERTY OF H_EXCEL 'Visible' = 1.

  • tell user what is going on

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

  • PERCENTAGE = 0

TEXT = TEXT-008

EXCEPTIONS

OTHERS = 1.

  • get list of workbooks, initially empty

CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.

  • add a new workbook

CALL METHOD OF H_MAPL 'OPEN' EXPORTING #1 = FNAME.

CALL METHOD OF H_MAPL 'EDITCELLDIRECTLY' = H_MAPL.

PERFORM FILL_CELL USING 6 8 1 VAL.

CALL METHOD OF H_EXCEL 'ActiveWorkbook' = H_MAPL.

CALL METHOD OF H_MAPL 'PrintOut' .

FREE OBJECT H_EXCEL.

FREE : H_EXCEL,H_MAPL,H_MAP,H_ACT.

But I am able to just print a Blank page.

Can some one tell me whats wrong?

Thanks,

Shashi Devi.