Code: Alles auswählen.
REPORT zshowworddoc MESSAGE-ID zerr.
TYPE-POOLS: sbdst.
INCLUDE officeintegrationinclude.
INCLUDE ole2incl.
PARAMETERS : pm_file TYPE rlgrap-filename DEFAULT 'c:\testword.doc'.
DATA: control TYPE REF TO i_oi_ole_container_control.
DATA: document TYPE REF TO i_oi_document_proxy.
DATA: container TYPE REF TO cl_gui_custom_container.
DATA: activeX.
DATA: ok_code TYPE sy-ucomm.
DATA: doc_url(255) TYPE c.
DATA: retcode TYPE t_oi_ret_string,
document_type TYPE soi_document_type,
document_format TYPE soi_document_type.
START-OF-SELECTION.
* Die URL !
CONCATENATE 'file://' pm_file INTO doc_url.
CALL SCREEN 100.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STAT0100'.
* SET TITLEBAR 'xxx'.
* Nur erzeugen falls noch nicht geschehen.
IF control IS INITIAL.
CALL FUNCTION 'GUI_HAS_ACTIVEX'
IMPORTING
return = activex.
IF activex IS INITIAL.
MESSAGE e000 WITH 'No ActiveX'.
ENDIF.
* Container
CALL METHOD c_oi_ole_control_creator=>get_ole_container_control
IMPORTING
control = control
retcode = retcode.
CALL METHOD c_oi_errors=>raise_message
EXPORTING
type = 'E'.
CREATE OBJECT container
EXPORTING container_name = 'CONTAINER'.
CALL METHOD control->init_control
EXPORTING
r3_application_name = 'Word97 Container'
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = container
register_on_close_event = 'X'
register_on_custom_event = 'X'
IMPORTING
retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
CALL METHOD c_oi_errors=>raise_message
EXPORTING
type = 'E'.
EXIT.
ENDIF.
* Word
CALL METHOD control->get_document_proxy
EXPORTING
document_type = 'Word.Document.8'
document_format = document_format
IMPORTING
document_proxy = document
retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
CALL METHOD c_oi_errors=>raise_message
EXPORTING
type = 'E'.
EXIT.
ENDIF.
IF NOT document IS INITIAL.
CALL METHOD document->close_document.
ENDIF.
* Open Dokument with URL -> filename
CALL METHOD document->open_document
EXPORTING
document_url = doc_url
open_inplace = 'X'
open_readonly = 'X'
IMPORTING
retcode = retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
DATA: l_ok_code TYPE sy-ucomm.
l_ok_code = ok_code.
CLEAR ok_code.
CALL METHOD cl_gui_cfw=>dispatch.
CASE l_ok_code.
WHEN 'BACK'.
PERFORM free_all.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form free_all
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM free_all .
IF NOT document IS INITIAL.
* Sichern beim Schliessen ?
* CALL METHOD document->close_document
* EXPORTING do_save = 'X'.
FREE document.
ENDIF.
IF NOT control IS INITIAL.
CALL METHOD control->destroy_control
IMPORTING
retcode = retcode.
FREE control.
ENDIF.
ENDFORM.
Code: Alles auswählen.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.