on 05-25-2005 5:17 PM
Hello gurus,
I need to create a new ms word document, write a variable text, insert an image, print the document and close it.
I am new at OLE programming. I have been checking the weblog of Sedar and the examples of SAP and have as a result the following code:
include ole2incl .
parameters: p_id type crmt_object_id.
data: gs_word type ole2_object,
gs_documents type ole2_object,
gs_newdoc type ole2_object,
gs_actdoc type ole2_object,
gs_picture(128).
start-of-selection .
gs_picture = 'c:\0000002257_01.TIF'.
create object gs_word 'WORD.APPLICATION'.
set property of gs_word 'Visible' = '1' .
call method of gs_word 'Documents' = gs_documents.
call method of gs_documents 'FileNew' = gs_newdoc
exporting
#1 = 'c:\my_doc.doc'.
call method of gs_word 'ActiveDocument' = gs_actdoc.
call method of gs_word 'TypeText'
exporting
#1 = p_id.
call method of gs_word 'InsertPicture'
exporting
#1 = gs_picture
#2 = '2'.
call method of gs_actdoc 'PrintOut' .
call method of gs_actdoc 'SaveAs'
exporting
#1 = 'c:\my_doc.doc'
#2 = 'wdFormatDocument'.
call method of gs_word 'Quit' .
end-of-selection.
free: gs_word, gs_actdoc, gs_documents, gs_newdoc.
Could anybody tell me why it is not working? I am using the SaveAs because the Quit returns sy-subrc = 2, and thougth it was possible that since I had modified the document, it was necesary to save it.
Thank you!
Paola
Hi,
Check this code i hope it will help you...
*****************
TYPE-POOLS ole2.
DATA:
o_word TYPE ole2_object,
excel TYPE ole2_object,
o_documents TYPE ole2_object,
o_actdoc TYPE ole2_object,
o_inlineshapes TYPE ole2_object,
o_logo TYPE ole2_object,
WORKBOOK TYPE ole2_object.
*CREATE OBJECT o_word 'Word.Application'.
CREATE OBJECT EXCEL 'Excel.Application'.
*FREE OBJECT EXCEL.
*SET PROPERTY OF o_word 'Visible' = '1'.
SET PROPERTY OF excel 'Visible' = '1'.
*GET PROPERTY OF o_word 'Documents' = o_documents.
GET PROPERTY OF excel 'Documents' = o_documents.
CALL METHOD OF o_documents 'Add' = o_actdoc.
CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOK.
GET PROPERTY OF o_actdoc 'InlineShapes' = o_inlineshapes.
CALL METHOD OF o_inlineshapes 'AddPicture' = o_logo
EXPORTING
#1 = 'C:\Temp\OTHERS\Scrap\COMPANY_LOGO.BMP'
#2 = 0
#3 = 1.
WRITE: / 'Test'.
***************************
Thanks.
I hope this will solve your purpose....
If solved give points and close the thread.
Message was edited by: Deepak333 k
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please! Anyone???
I am sure you're tired of checking this kind of code, but I need help!
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Paola,
have you solved this problem? I need to export a picture from server to word with and I cannot do it. In addition, when I export the picture from PC to word, I cannot modify the size and the image appears very high. Could you tell me if you can modify the size image?
Thank you.
Best Regards.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.