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: 

Want FM to print word doc.

vallamuthu_madheswaran2
Active Contributor
0 Kudos

Hi friends,

i want to print "confirmation letter" to MS-word document. is there any FM or sample program?.

Thanks & Regards.

Vallamuthu.M

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

Prints the file without interfering the user:

INCLUDE ole2incl .
DATA: v_word TYPE ole2_object ,
v_documents TYPE ole2_object ,
v_newdoc TYPE ole2_object ,
v_actdoc TYPE ole2_object .

START-OF-SELECTION .
  CREATE OBJECT v_word 'WORD.APPLICATION'.
  SET PROPERTY OF v_word 'Visible' = '0' .
  CALL METHOD OF v_word 'Documents' = v_documents.
  CALL METHOD OF v_documents 'Open' = v_newdoc
    EXPORTING
    #1 = 'C:\Documents and Settings\jyrj\Desktop\Functional Specs\just for print.doc'.
  CALL METHOD OF v_word 'ActiveDocument' = v_actdoc .
  CALL METHOD OF v_actdoc 'PrintOut' .
  CALL METHOD OF v_word 'Quit' .

END-OF-SELECTION.
  FREE: v_word, v_actdoc, v_documents, v_newdoc.

11 REPLIES 11

Former Member
0 Kudos

Hi ,

Try method EXECUTE of class CL_GUI_FRONTEND_SERVICES .

Pass file name and parameter Operation as PRINT.

Hope it helps.

Former Member
0 Kudos

hi

Check with

FM CV150_PRINT_DOC

Thanks!

Former Member
0 Kudos

hi ,

you must use ABAP OLE , check this example :

type-pools ole2 .
 
CREATE OBJECT word 'WORD.APPLICATION' .
  IF sy-subrc NE 0 .
    MESSAGE s000(su) WITH 'Error while creating OLE object!'.
    LEAVE PROGRAM .
  ENDIF .
 
  GET PROPERTY OF word 'documents' = documents.
  CALL METHOD OF documents 'Add' = newdoc.
 
  GET PROPERTY OF word 'Selection' = selection.
 
  call method of selection 'TypeText'
    exporting
    #1 = 'Some data'.
 
  call method of selection 'HomeKey'
    exporting
      #1 = 5
      #2 = 1.
 
  get property of selection 'Font' = font.
  set property of font 'Bold' = 1.

check this link :

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/204d1bb8-489d-2910-d0b5-cdddb322...

0 Kudos

I want save the word doc in particular path also.

Thanks & Regards,

Vallamuthu.M

0 Kudos

Hi,

use GUI_DOWNLOAD FM

former_member156446
Active Contributor
0 Kudos

Prints the file without interfering the user:

INCLUDE ole2incl .
DATA: v_word TYPE ole2_object ,
v_documents TYPE ole2_object ,
v_newdoc TYPE ole2_object ,
v_actdoc TYPE ole2_object .

START-OF-SELECTION .
  CREATE OBJECT v_word 'WORD.APPLICATION'.
  SET PROPERTY OF v_word 'Visible' = '0' .
  CALL METHOD OF v_word 'Documents' = v_documents.
  CALL METHOD OF v_documents 'Open' = v_newdoc
    EXPORTING
    #1 = 'C:\Documents and Settings\jyrj\Desktop\Functional Specs\just for print.doc'.
  CALL METHOD OF v_word 'ActiveDocument' = v_actdoc .
  CALL METHOD OF v_actdoc 'PrintOut' .
  CALL METHOD OF v_word 'Quit' .

END-OF-SELECTION.
  FREE: v_word, v_actdoc, v_documents, v_newdoc.

0 Kudos

Hi ,

is there any method/class for "Next Page".

is there any method/class for next line and how to find the properties/object (eg: font, paragraph,table properties).

Thanks & Regards,

Vallamuthu.M

Edited by: vallamuthu madheswaran on Apr 22, 2009 11:04 AM

Edited by: vallamuthu madheswaran on Apr 22, 2009 3:33 PM

0 Kudos

EPS_GET_FILE_ATTRIBUTES will get the attributes of file, but to get he font and other properties which are in the file is not possible to get.

0 Kudos

Hi,

How to give the "New Page" or "Next page"?

Thanks & Regards,

Vallamuthu.M

0 Kudos

I have tested it... if the word document has 3 pages all the pages are getting printed.

0 Kudos

Hi,

I'm having 15 line word document for a vendor.

if i give 30 vendor then it print 30 pages but here i gave more than one vendor the allignment is not properly.

Thanks & Regards,

Vallamuthu.M