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: 

data not getting correctly when downloading on to msword when using ole method

Former Member
0 Kudos
66

Dear Freinds,
           I have an issue getting a second heading description when iam getting data downloaded to MS WORD  using OLE . iam able to get the first heading successfully however when iam tring for second
heading it is coming adjuscent to it instead of coming next line....could any one please help in relating to this.

The code i have used is ....
CREATE OBJECT gs_word 'WORD.APPLICATION'. "Create word object
*  Setting object's visibility property
    SET PROPERTY OF gs_word 'Visible' = 0.
*  Opening a new document
    CALL METHOD OF
        gs_word
        'Documents' = gs_documents.
    CALL METHOD OF
        gs_documents
        'Add'        = gs_document.
*  Activating the sheet
    CALL METHOD OF
        gs_document
        'Activate'.
* Getting active document handle
    GET PROPERTY OF gs_word 'ActiveDocument' = gs_actdoc.
*  Getting applications handle
    GET PROPERTY OF gs_actdoc 'Application' = gs_application.
* Getting handle for the selection which is here the character at the cursor position
    GET PROPERTY OF gs_application 'Selection' = gs_selection.
    GET PROPERTY OF gs_selection 'Font' = gs_font.
    GET PROPERTY OF gs_selection 'ParagraphFormat' = gs_parformat.

    SET PROPERTY OF gs_font 'Name' = 'Arial'.
    SET PROPERTY OF gs_font 'Size' = '12'.   "'16'.
    SET PROPERTY OF gs_font 'Bold' = '1'.
    SET PROPERTY OF gs_font 'Italic' = '1'.
*    SET PROPERTY OF gs_font 'Underline' = '1'.
    SET PROPERTY OF gs_parformat 'Alignment' = '1'. " Centered

      CALL METHOD OF
        gs_selection
        'TypeText'
      EXPORTING
        #1           = 'Bank Transfer Details'.

   concatenate ' Bank Name' ':' V_BANK into v_bankname.

     CALL METHOD OF
        gs_selection
        'TypeText'
      EXPORTING
        #2           = v_bankname.


Now when i see my output i can see the data coming is  Bank Transfer Details Bank Name : ICICI.


i wanted that to come as
               Bank Transfer Details
Bank name : ICICI.


Please let me know where i went wrong.


Thanks & Regards
Syamala.

2 REPLIES 2

former_member186741
Active Contributor
0 Kudos
34

what you need to do is insert a line-feed or a new paragraph between your two texts.

you could probably do this by cocatenating a line-feed(x'0a') or carriage return(x'0d') to the front of 'bank name in your abap code.

or you could try vba method InsertParagraphAfter.

Former Member
0 Kudos
34

HI Syamala,

I faced the same issue, and solved that with below codings, hope will help you.

GS_RANGE TYPE OLE2_OBJECT,

    GV_POS(5) TYPE N,

    * Get current cursor position after filling up first text

  GET PROPERTY OF GS_RANGE 'End'   = GV_POS .

  SET PROPERTY OF GS_RANGE 'Start' = '00200'.

  CALL METHOD OF GS_RANGE 'Select' .

* Goto the next line - 5 lines down

  DO 3 TIMES.

    CALL METHOD OF GS_SELECTION 'TypeParagraph'.

  ENDDO.

SET PROPERTY OF GS_PARFORMAT 'Alignment' = '1' . "Centered

CALL METHOD OF GS_SELECTION 'TypeText'

EXPORTING

#1 = 'SECOND HEADING'." type your text for second heading in our example Bank name : ICICI.

*--Advancing cursor to the new line

CALL METHOD OF GS_SELECTION 'TypeParagraph' .

Regards,

Saravana.S