Skip to Content
0
May 05, 2011 at 10:11 AM

ABAP and MS Word integration - The Old Way :o)

564 Views

Hi Guys

About five or 6 years ago I made a program which worked with OLE integration to Word. The program is still used. And I don't want to spend time recoding the program to the New Way Of Officeintegration! The way the program was made as follows

CREATE OBJECT gs_word 'WORD.APPLICATION'.
SET PROPERTY OF gs_word 'VISIBLE' = '1'.
 
CALL METHOD OF gs_word 'Documents' = gs_documents.
CALL METHOD OF gs_documents 'Add' = gs_document.
CALL METHOD OF gs_document 'Activate'.
 
** Gets the cursor position
GET PROPERTY OF gs_word 'SELECTION' = gs_selection.
* ..... much more coding!

I have had no problems by calling methods and getting properties of Word.

But now I have to use the Change command.

In a Word MACRO it looks like:

Selection.Find.ClearFormatting

Selection.Find.Replacement.ClearFormatting

With Selection.Find

.Text = "Change from"

.Replacement.Text = "Change to"

.Forward = True

.Wrap = wdFindContinue

.Format = False

.MatchCase = False

.MatchWholeWord = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

End With

Selection.Find.Execute Replace:=wdReplaceAll

How do I write the "With Selection.Find" command in my ABAP code?

Best regards

Carsten