Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

OLE2: How do I call a method with key parameters ?

Former Member
0 Kudos

Dear fellow developers,

my ABAP keyword documentation tells me that I can use

the EXPORTING parameter of CALL METHOD OF only for

enumerated parameters using #1 = value1 #2 = value2

and so on.

I'm trying to call up the "Execute" - method of the

MS WORD-class "Find", which uses a lot of optional

named parameters. Does anybody know how I can call

a method like that.

thanks in advance for your help

Andreas

2 REPLIES 2

Former Member
0 Kudos

Hi,

Hope this will help you....

the Execute Method of Object is called this way

WORD.FIND.EXECUTE with parameters [FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap],etc

in ABAP to drill down to EXECUTE method

CREATE OBJECT GS_WORD 'WORD.APPLICATION' .

GET PROPERTY OF GS_WORD 'FIND' = GS_FIND.

CALL METHOD OF GS_FIND 'EXECUTE'

exporting

#1 = 'text' ( the text we are looking for)

#2 = for [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap],etc set a boolean value 'X'.

Regards,

Vara

0 Kudos

Dear Vara,

can you make it work this way? Unfortunetaly I don't.

The parameters don't have fixed positions in the

parameter list and need to be called with the parameter

names, in VBA you have to call them like

WORD.FIND.EXECUTE FindText:="to be replaced", ReplaceWith:="hello", Replace:=wdReplaceAll.

As I understand you could as well change the order of

the parameters called like

WORD.FIND.EXECUTE ReplaceWith:="hello", Replace:=wdReplaceAll, FindText:="to be replaced",

as long as you provide the parameter values along with

their names to the function.

I think that's why using the #1, #2 - notation doesn't

work. I thought there might possibly be some kind of

trick like putting the entire parameter list into the first numbered parameter or something like that.

Thanks a lot

Andreas