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: 

Replace statement is not working in OLE

Former Member
0 Kudos
381

Hi

I am generating the excel using OLE and in excel i want ot use replace staement for a column . I want to write the code for that . In excel macro i found some code for that and it is mentioned below

Selection.Replace What:="'", Replacement:="", LookAt:=xlPart, _

SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _

ReplaceFormat:=False

I have convert this in ABAP but it is not working Please find the code in abap

CALL METHOD OF gs_cells_temp 'Replace'

EXPORTING

#1 = '1'

#2 = ' 2'

#3 = 2

#4 = 1

#5 = 'False'

#6 = 'False'

#7 = 'False'.

Can anyone help me in this regard.

3 REPLIES 3

Former Member
0 Kudos
224

Closed

0 Kudos
224

Hi Amit,

I am facing the same issue, can you advice?

Thanks in advance,

Hung

former_member189059
Active Contributor
0 Kudos
224

I know this is a very 'early' reply, but I was searching for the same solution.

Finally managed it myself. The solution could help others as well.

  data: lo_xl_activesheet type ole2_object.
  data: lo_xl_allcells type ole2_object.
  data: lo_xl_activecell type ole2_object.

" lo_xl_activesheet is set to a worksheet using WORKSHEETS

  call method of lo_xl_activesheet 'CELLS' = lo_xl_allcells.
  call method of lo_xl_allcells 'FIND' = lo_xl_activecell
    EXPORTING
       #1 = '<<name_01_01>>'.

  call method of lo_xl_activecell 'REPLACE'
    EXPORTING
       #1 = '<<name_01_01>>'
       #2 = 'NewValue'.