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

ECC6Ehp5 abap call OLE have error

Dear All,

Our system from ECC5 upgrade to ECC6 Ehp5,Now we have some abap program cann't used it,We checked it,They are all call OLE write data to word.The program source code:

program zchangeword.

INCLUDE ole2incl .

DATA gs_word TYPE ole2_object . "OLE object handle

DATA gs_documents TYPE ole2_object .

DATA gs_actdoc TYPE ole2_object .

DATA gs_application TYPE ole2_object .

DATA gs_selection TYPE ole2_object .

DATA gs_bookmark TYPE ole2_object.

DATA gs_count TYPE ole2_object.

DATA gs_actwindow TYPE ole2_object.

DATA gs_actpane TYPE ole2_object.

DATA gs_view TYPE ole2_object.

DATA gs_font TYPE ole2_object.

DATA docpath TYPE string.

DATA l_dokst TYPE tdws-dokst.

docpath = 'c:\temp\20111124121443_TCDEV0101.doc'.

CREATE OBJECT gs_word 'WORD.APPLICATION' .

IF sy-subrc NE 0 .

MESSAGE 'Error while creating OLE object!' TYPE 'I'.

LEAVE PROGRAM .

ENDIF .

SET PROPERTY OF gs_word 'Visible' = '1' .

GET PROPERTY OF gs_word 'Documents' = gs_documents .

CALL METHOD OF

gs_documents

'Open'

EXPORTING

#1 = docpath.

GET PROPERTY OF gs_word 'ActiveDocument' = gs_actdoc .

CALL METHOD OF

gs_actdoc

'Unprotect'.

GET PROPERTY OF gs_actdoc 'Bookmarks' = gs_bookmark.

GET PROPERTY OF gs_bookmark 'Count' = gs_count.

GET PROPERTY OF gs_actdoc 'Application' = gs_application .

GET PROPERTY OF gs_application 'Selection' = gs_selection .

PERFORM replace USING 'Y0_NAME' 'TEST'.

PERFORM replace USING 'Y0_DATE' '2011.11.24'.

***关闭WORD文件

CALL METHOD OF

gs_actdoc

'Close'

EXPORTING

#1 = '-1'.

CALL METHOD OF

gs_word

'Quit'.

FREE OBJECT: gs_word,gs_documents,gs_actdoc,gs_application,gs_selection.&----


*& Form replace

&----


* text

----


* -->P_FINDTEXT text

  • -->P_REPLACETEXT text

----


FORM replace USING p_findtext

p_replacetext.

CALL METHOD OF

gs_selection

'GoTo'

EXPORTING

#1 = '-1'

#2 = 0

#3 = 0

#4 = p_findtext.

CALL METHOD OF

gs_selection

'MoveEnd'

EXPORTING

#1 = '5'

#2 = '1'.

CALL METHOD OF

gs_selection

'Delete'.

  • CALL METHOD OF GS_FIND 'ClearFormatting'.

  • CALL METHOD OF GS_FIND 'Execute'.

CALL METHOD OF

gs_selection

'TypeText'

EXPORTING

#1 = p_replacetext.

ENDFORM. " REPLACE

The code line "GET PROPERTY OF gs_word 'Documents' = gs_documents ."

If the ERP system is ECC5.0,the variable gs_documents can return value,

But system is ECC6 Ehp5 the variable gs_documents cann't return value,Then the program cann't change the word file,Who can help me?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 25, 2011 at 09:48 AM

    Who can help we?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 25, 2011 at 11:10 AM

    Check for differences in transaction SOLE

    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.