This website is not affiliated with, sponsored by, or approved by SAP AG.

Word OLE - How to fill table

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: thx4allthefish, Snowy, Gothmog, YuriT

Word OLE - How to fill table

Postby candrade » Fri Mar 30, 2012 9:53 am

Hi,
I have a word document that has a fixed table with 6 fixed fields (collums) and variable rows that I need to fill.

My abap program calls this document Word by OLE commands and fills anothers informations,
like the way bellow

CALL METHOD OF zword 'WW2_EDITREPLACE' EXPORTING #1 = '#cod_prov#'

but I do know how to fill table. This table I can change to excel table.
Will be grateful if you can kindly help me out.

Thanking You,
Kind Regards

candrade
 
Posts: 3
Joined: Fri Mar 30, 2012 9:30 am

Re: Word OLE - How to fill table

Postby Gothmog » Fri Mar 30, 2012 9:58 am

Record a macro while doing it manually in Word, you'll see the objects and methods to use.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1467
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Word OLE - How to fill table

Postby candrade » Wed Apr 04, 2012 9:29 am

Thank's Gothmog,
But I've created a macro, but I still don't know how to edit a table that exists in a document word. I see codes that create
a table and fill fields, but I didn't see editing a table that was not created by the abap program. Is that possible?
candrade
 
Posts: 3
Joined: Fri Mar 30, 2012 9:30 am

Re: Word OLE - How to fill table

Postby Gothmog » Wed Apr 04, 2012 9:42 am

ActiveDocument.Tables should get you a collection of table objects in the document.
You can get the specific table by its index in the collection - ActiveDocument.Tables(i) - then access its methods and properties.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1467
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Word OLE - How to fill table

Postby candrade » Mon Apr 09, 2012 10:15 am

Thank's. I tried but doesn´t work, maybe because I'm using Word.basic. Can anybody help me?
The code is

Code: Select all
CREATE OBJECT zsdprop 'WORD.BASIC'.

  CALL METHOD OF
      zsdprop
      'APPSHOW'.

  CALL METHOD OF
      zsdprop
      'FILEOPEN'

    EXPORTING
      #1         = p_file.

  CALL METHOD OF
      zsdprop
      'EDITSELECTALL'.

  CALL METHOD OF
      zsdprop
      'EDITCOPY'.

  CALL METHOD OF
      zsdprop
      'DOCCLOSE'

    EXPORTING
      #1         = 2.

  CALL METHOD OF
      zsdprop
      'FILENEW'.

  CALL METHOD OF
      zsdprop
      'EDITPASTE'.
*  ENDAT.

  CALL METHOD OF
      zsdprop
      'STARTOFDOCUMENT'.

if sy-subrc ne 0.
    MESSAGE s002 WITH text-014.
    STOP.
endif.

CALL METHOD OF
      zsdprop
      'WW2_EDITREPLACE'

    EXPORTING
      #1                = lv_fword
      #2                = p_field.

  CALL METHOD OF
      zsdprop
      'FILEPRINT'

    EXPORTING
      #1          = 'Documento1'.

  CALL METHOD OF
      zsdprop
      'DOCCLOSE'

    EXPORTING
      #1         = 2.

  CALL METHOD OF
      zsdprop
      'APPCLOSE'.

  FREE OBJECT zsdprop.
candrade
 
Posts: 3
Joined: Fri Mar 30, 2012 9:30 am


Return to ABAP

Who is online

Users browsing this forum: Google [Bot] and 6 guests




This website is not affiliated with, sponsored by, or approved by SAP AG.