Skip to Content
avatar image
Former Member

Word ole Question Problem

HI all,

Could you help me with solving a similar problem? I need to delete a row from a Table in WORD document.. I've recorded the macro in Word , but did not manage to translate it correctly to ABAP. What's wrong below? Please, help.

This is the macro VBA:


* sText = InputBox("Enter text for Row to be deleted")


With Selection.Find

.Text = sText

.Wrap = wdFindContinue

End With

Do While Selection.Find.Execute

If Selection.Information(wdWithInTable) Then


End If



This is my Abap Code .

data: clear type ole2_object.

data: word type ole2_object.

data: execute type ole2_object.

data: information type ole2_object.

data: row type ole2_object.

data: selection type ole2_object.

data: find type ole2_object, wdFindContinue type ole2_object,

delete TYPE ole2_object. .

CALL METHOD OF h_word 'ClearFormatting' = clear.

GET PROPERTY OF clear 'Selection' = selection.

GET PROPERTY OF selection 'find' = find.

SET PROPERTY OF find 'Text' = ' (D)'.

SET PROPERTY OF find 'Wrap' = wdFindContinue.

CALL METHOD OF find 'Execute' = execute.

GET PROPERTY OF selection 'Information' = information.

set PROPERTY OF selection 'Rows' = row.

CALL METHOD of row 'Delete' .


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jul 06, 2017 at 01:48 AM

    You must swap a few things in the first lines.

    Assuming you have correctly created the object H_WORD, you must then do:

    For selection.find.clearformatting :

    GET PROPERTY OF h_word 'Selection' = selection.
    GET PROPERTY OF selection 'find' = find. 
    CALL METHOD OF find 'ClearFormatting'. 


    But why don't you go for abap2xlsx. It's more easy for a developer, much faster, and it works in background. But you can't create your code from the VBA, you must create the code from scratch (and eventually reuse a template workbook if you want).

    Add comment
    10|10000 characters needed characters exceeded

    • Ask the users if they can use the format .DOCX (the classic contraindication is that some of the target users have an old MS Word software version, which can't open .DOCX documents). If it's possible, they just have to save their template into .DOCX, nothing more.