Skip to Content
author's profile photo Former Member
Former Member

SAP OLE to Excel Page Set Up option

I am using sap OLE concept to convert it into excel.. I have use page set up option, But i need to chage the orientation to landscape and change the margin sizes but i am not able to do that with the coding ? to change in this follwing code can any one help to proceed further

CALL METHOD OF h_excel 'ACTIVESHEET' = activesheet.

GET PROPERTY OF activesheet 'PageSetup' = pagesetup.

SET PROPERTY OF pagesetup 'Zoom' = 65.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Mar 27, 2009 at 06:49 AM

    Hello,

    Try this for Landscape (all ole objects are of type OLE2_OBJECT)

    CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.
    
    IF SY-SUBRC NE 0.
      WRITE: / 'No EXCEL creation possible'.
      STOP.
    ENDIF.
    
    SET PROPERTY OF EXCEL 'DisplayAlerts' = 0.
    
    CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOK .
    
    SET PROPERTY OF EXCEL 'VISIBLE' = 1.
    
    
    * creating workbook
    SET PROPERTY OF EXCEL 'SheetsInNewWorkbook' = 1.
    CALL METHOD OF WORKBOOK 'ADD'.
    
    CALL METHOD OF EXCEL 'WORKSHEETS' = SHEET.
    CALL METHOD OF SHEET 'ADD'.
    FREE OBJECT SHEET.
    
    CALL METHOD OF EXCEL 'WORKSHEETS' = SHEET
      EXPORTING
        #1 = 1.
    
    GET PROPERTY OF sheet 'PageSetup' = h_pagesetup.
    
    set PROPERTY OF h_pagesetup 'Orientation' = 2.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 27, 2009 at 06:57 AM

    Margin sizes are in points, All are attributes of H_PAGESETUP

    eg:

    SET PROPERTY OF h_pagesetup 'LeftMargin' = 140.

    Other properties include

    RightMargin

    TopMargin

    BottomMargin

    HeaderMargin

    FooterMargin

    Zoom (in percentage)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.