SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Demo OLE 2.0: Open Excel or WinWord



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Mon Nov 05, 2007 12:37 pm    Post subject: Demo OLE 2.0: Open Excel or WinWord Reply with quote

Code:

PROGRAM RSOLETT1 MESSAGE-ID SY.

INCLUDE OLE2INCL.

DATA: FILENAME(100).
DATA: DOCUMENT(28) VALUE '*.DOC'.
DATA: OKCODE(5).
DATA CUSTOMER(10).

DATA: H_SHEET TYPE OLE2_OBJECT.
DATA: H_APPL  TYPE OLE2_OBJECT.
DATA: H_WORK  TYPE OLE2_OBJECT.
DATA: H_CELL  TYPE OLE2_OBJECT.


*---------------------------------------------------------------------*
*       MODULE D100 OUTPUT                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE D100 OUTPUT.
  SET PF-STATUS 'MAIN'.
ENDMODULE.

*---------------------------------------------------------------------*
*       MODULE D100 INPUT                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE D100 INPUT.

  CASE OKCODE.
    WHEN 'EXIT'. PERFORM LEAVE.
    WHEN 'BACK'. PERFORM LEAVE.
*
*   Excel Example
*
    WHEN 'EXST'.
*     start Excel
      IF H_APPL-HEADER = SPACE OR H_APPL-HANDLE = -1.
        CREATE OBJECT   H_APPL  'EXCEL.APPLICATION'.
        IF SY-SUBRC NE 0. MESSAGE I002 WITH SY-MSGLI. ENDIF.
        SET PROPERTY OF H_APPL  'VISIBLE' = 1.
      ENDIF.

    WHEN 'EXRE'.
*      release Excel
      CALL METHOD OF    H_APPL  'QUIT'.
      FREE OBJECT H_APPL.
      H_APPL-HANDLE = -1.
*
*   Word Example
*
      DATA: H_WORD  TYPE OLE2_OBJECT.

    WHEN 'STAR'.
*      start Word
      IF H_WORD-HEADER = SPACE OR H_WORD-HANDLE EQ -1.
        CREATE OBJECT H_WORD  'WORD.BASIC'.
        IF SY-SUBRC NE 0.
          MESSAGE I002 WITH SY-MSGLI.
        ELSE.
          CALL METHOD OF H_WORD 'AppShow'.
        ENDIF.
      ENDIF.


    WHEN 'ENDE'.
*     release Word
      CALL METHOD OF H_WORD 'APPCLOSE'.
      FREE OBJECT H_WORD.
      H_WORD-HANDLE = -1.

  ENDCASE.
  CLEAR OKCODE.
ENDMODULE.

*---------------------------------------------------------------------*
*       FORM LEAVE                                                    *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM LEAVE.
  SET SCREEN 0.
  LEAVE SCREEN.
ENDFORM.

*Text elements
*----------------------------------------------------------
* 001 Entry in SAP-DATA field incorrect
* 002 Calculator can now be used
* 003 Open file


*Messages
*----------------------------------------------------------
*
* Message class: SY
*002   &
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.