Skip to Content
0
Former Member
Jun 21, 2010 at 08:37 PM

OLE: Why placeholders of MS Word document are not replaced?

495 Views

Hi Experts, I am using OLE to create Word Documents within a LOOP. The problem I have is that the Word Documents are created and seved well but the placeholders (&nom_prov') and (&ncod_prov') are not replaces by the values (in the example: test1 and test2).

Anybody can help me in with that issue?

LOOP AT lt_partner1 INTO ls_partner1.
 
  AT FIRST.
    CREATE OBJECT zword 'WORD.BASIC'.
    CALL METHOD OF zword 'FILEOPEN' EXPORTING #1 = 'C:\DOCS\PRUEBA_1.DOC'.
  ENDAT.
 
  CALL METHOD OF zword 'EDITSELECTALL'.
  CALL METHOD OF zword 'EDITCOPY'.
  CALL METHOD OF zword 'FILENEW'.
  CALL METHOD OF zword 'EDITPASTE'.
  CALL METHOD OF zword 'STARTOFDOCUMENT'.
  
 CALL METHOD OF zword 'WW2_EDITREPLACE' EXPORTING #1 = '&cod_prov'
    #2 = 'test 1'. "ls_partner1-nif.
  CALL METHOD OF zword 'WW2_EDITREPLACE' EXPORTING #1 = '&nom_prov'
    #2 = 'test 2'. "ls_partner1-name_org1.
 
  CALL METHOD OF zword 'STARTOFDOCUMENT'.
  CALL METHOD OF zword 'EDITSELECTALL'.
  CALL METHOD OF zword 'EDITCLEAR'.
  CALL METHOD OF zword 'EDITPASTE'.
  lv_contador = lv_contador + 1.
  CONCATENATE 'C:\DOCS\' 'PRUEBA' lv_contador '_' sy-datum '.DOC' INTO  lv_file_save_as.
  CALL METHOD OF zword 'FILESAVEAS' EXPORTING #1 = lv_file_save_as.
  CALL METHOD OF zword 'DOCCLOSE' EXPORTING #1 = 2.
  
 AT LAST.
   CALL METHOD OF zword 'APPCLOSE'.
   FREE OBJECT zword.
 ENDAT.
 
ENDLOOP.