‎2005 Aug 11 6:33 AM
Hi,
How to pass values to the exporting parameters for the following methods?
I have created a object as
create object gs_word 'Word.Basic'.
call method of gs_word 'Filenew'
exporting
#1 = ????.
Now I want to display a table in word by using the object created.Kindly let me know how I should proceed with this.
Any help will be highly appreciated.
Thanks in Advance.
Regards,
J.Jayanthi
Message was edited by: Jayanthi Jayaraman
‎2005 Aug 11 12:28 PM
Hi,
This type of programming is related to OLE Automation.
Here each method may provide an object as result.
You have to view the WORD Document to view the result.
in the Word Documet activate the VB Editor and open the <b>OBJECT BROWSER SCREEN</b> and check the methods. The methods that you have used are of the WORD Document. Now each method can return an Object. So, you can only know the output of the method only when you view the WORD DOCUMENT.
check the below link for reference.
<b>http://help.sap.com/saphelp_46c/helpdata/en/59/ae3f2e488f11d189490000e829fbbd/frameset.htm</b>
There is an example of an excel sheet in the documentation.
Hope it would be of some help to you.
Regards,v
Vara
‎2005 Aug 12 1:22 PM
Hi,
Thanks a lot for your information.
It is very much useful.
But I am not able to find WORD.BASIC in my object browser.
I am able to find EXCEL.APPLICATION and WORD.APPLICATION.
But in TOLE table,WORD.APPLICATION is not there.
But WORD.BASIC is in the table.
Can you tell me any other methos for finding the parameters.
Waiting for your reply.
‎2005 Aug 13 12:23 PM
you can still use word.application instead of word.basic
for requirement of showing a table in word check the following tutorial, it has got the code sample for table.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/technologies/an%20easy%20reference%20for%20ole%20automation.article">An Easy Reference for OLE Automation</a>
Regards
Raja
‎2005 Aug 16 5:18 AM
Hi Raja,
Thanks for replying.
I already tried coying the same code in that link for WORD.APPLICATION.
It is opening the document.But not showing the table.
If I copied the code for EXCEL.APPLICATION,it is working perfectly.
So I think since WORD.APPLICATION is not in TOLE table,I cannot use it.
If it is possible to WORD.APPLICATION even it is not in TOLE table,kindly let me know how I should proceed.
Waiting for your reply.
Thanks and Regards,
J.Jayanthi
‎2005 Aug 16 5:24 AM
i have tried the same code and it works fine. the following are entries in my TOLE table
WORD.BASIC
WORD97
WORDPRO.APPLICATION
Probably the issue could be the versin of Word you are using. i tried it with word2003. which version of word are you using. if its still dosent work. let me know. i will write up a simple program for testing.
Regards
Raja
‎2005 Aug 16 5:51 AM
Hi Raja,
TOLE table:
App Version
WORD.BASIC 6
WORD97
WORDPRO.APPLICATION
I am using word 2003 version 11.0.
If I am using the code sample,it is displaying 'This is an OLE example' only in a opened document.
I copied the entire coding for Word given there.
Kindly help me to proceed further.
Waiting for your reply.
‎2005 Aug 16 5:58 AM
you tole entries look exactly the same as mine.
below given is the code copied from the referenced document and its working fine. copy paste the below code and give it a try and let us know.
REPORT Y_WORD_TEST1.
*--Include for OLE-enabling definitions
INCLUDE ole2incl .
*--Global variables
*--Variables to hold OLE object and entity handles
DATA gs_word TYPE ole2_object . "OLE object handle
DATA gs_documents TYPE ole2_object . "Documents
DATA gs_actdoc TYPE ole2_object . "Active document
DATA gs_application TYPE ole2_object . "Application
DATA gs_options TYPE ole2_object . "Application options
DATA gs_actwin TYPE ole2_object . "Active window
DATA gs_actpan TYPE ole2_object . "Active pane
DATA gs_view TYPE ole2_object . "View
DATA gs_selection TYPE ole2_object . "Selection
DATA gs_font TYPE ole2_object . "Font
DATA gs_parformat TYPE ole2_object . "Paragraph format
DATA gs_tables TYPE ole2_object . "Tables
DATA gs_range TYPE ole2_object . "Range handle for various ranges
DATA gs_table TYPE ole2_object . "One table
DATA gs_table_border TYPE ole2_object . "Table border
DATA gs_cell TYPE ole2_object . "One cell of a table
DATA gs_paragraph TYPE ole2_object . "Paragraph
DATA gv_pos(5) TYPE n . "Position information for table
START-OF-SELECTION .
*--Creating OLE object handle variable
CREATE OBJECT gs_word 'WORD.APPLICATION' .
IF sy-subrc NE 0 .
MESSAGE s000(su) WITH 'Error while creating OLE object!'.
LEAVE PROGRAM .
ENDIF .
*--Setting object's visibility property
SET PROPERTY OF gs_word 'Visible' = '1' .
*--Opening a new document
GET PROPERTY OF gs_word 'Documents' = gs_documents .
CALL METHOD OF gs_documents 'Add' .
*--Getting active document handle
GET PROPERTY OF gs_word 'ActiveDocument' = gs_actdoc .
*--Getting applications handle
GET PROPERTY OF gs_actdoc 'Application' = gs_application .
*--Setting the measurement unit
GET PROPERTY OF gs_application 'Options' = gs_options .
SET PROPERTY OF gs_options 'MeasurementUnit' = '1' . "CM
*--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 .
*--Setting font attributes
SET PROPERTY OF gs_font 'Name' = 'Arial' .
SET PROPERTY OF gs_font 'Size' = '10' .
SET PROPERTY OF gs_font 'Bold' = '0' . "Not bold
SET PROPERTY OF gs_font 'Italic' = '1' . "Italic
SET PROPERTY OF gs_font 'Underline' = '0' . "Not underlined
*--Setting paragraph format attribute
SET PROPERTY OF gs_parformat 'Alignment' = '2' . "Right-justified
CALL METHOD OF gs_selection 'TypeText'
EXPORTING
#1 = 'This is an OLE example!'.
*--Setting the view to the main document again
SET PROPERTY OF gs_view 'SeekView' = '0' . "Main document view
*--Reseting font attributes for the title
SET PROPERTY OF gs_font 'Name' = 'Times New Roman' .
SET PROPERTY OF gs_font 'Size' = '16' .
SET PROPERTY OF gs_font 'Bold' = '1' . "Bold
SET PROPERTY OF gs_font 'Italic' = '0' . "Not Italic
SET PROPERTY OF gs_font 'Underline' = '0' . "Not underlined
*--Setting paragraph format attribute
SET PROPERTY OF gs_parformat 'Alignment' = '1' . "Centered
CALL METHOD OF gs_selection 'TypeText'
EXPORTING
#1 = text-000.
*--Advancing cursor to the new line
CALL METHOD OF gs_selection 'TypeParagraph' .
*--Reseting font attributes for ordinary text
SET PROPERTY OF gs_font 'Name' = 'Times New Roman' .
SET PROPERTY OF gs_font 'Size' = '12' .
SET PROPERTY OF gs_font 'Bold' = '0' . "Not bold
SET PROPERTY OF gs_font 'Italic' = '0' . "Not Italic
SET PROPERTY OF gs_font 'Underline' = '0' . "Not underlined
*--Setting paragraph format attribute
SET PROPERTY OF gs_parformat 'Alignment' = '3' . "Justified
CALL METHOD OF gs_selection 'TypeText'
EXPORTING
#1 = text-001.
*--Skip some lines
DO 4 TIMES .
CALL METHOD OF gs_selection 'TypeParagraph' .
enddo.
*--Getting entity handles for the entities on the way
GET PROPERTY OF gs_actdoc 'Tables' = gs_tables .
GET PROPERTY OF gs_selection 'Range' = gs_range .
*--Adding a table with 3 rows and 2 columns
CALL METHOD OF gs_tables 'Add' = gs_table
EXPORTING
#1 = gs_range " Handle for range entity
#2 = '3' "Number of rows
#3 = '2'. "Number of columns
*--Setting border attribute for the table
GET PROPERTY OF gs_table 'Borders' = gs_table_border .
SET PROPERTY OF gs_table_border 'Enable' = '1' . "With border
*--Filling the table with dummy data
*--Reseting font attributes for table content
SET PROPERTY OF gs_font 'Name' = 'Garamond' .
SET PROPERTY OF gs_font 'Size' = '11' .
SET PROPERTY OF gs_font 'Bold' = '0' . "Not bold
SET PROPERTY OF gs_font 'Italic' = '0' . "Not Italic
SET PROPERTY OF gs_font 'Underline' = '0' . "Not underlined
*--Getting cell coordinates
CALL METHOD OF gs_table 'Cell' = gs_cell
EXPORTING
#1 = '1' "first row
#2 = '1'. "first column
*--Getting the range handle to write the text
GET PROPERTY OF gs_cell 'Range' = gs_range .
*--Filling the cell
SET PROPERTY OF gs_range 'Text' = 'OLE' .
*--Getting cell coordinates
CALL METHOD OF gs_table 'Cell' = gs_cell
EXPORTING
#1 = '3' "third row
#2 = '2'. "second column
*--Getting the range handle to write the text
GET PROPERTY OF gs_cell 'Range' = gs_range .
*--Filling the cell
SET PROPERTY OF gs_range 'Text' = 'OLE' .
*--Advancing the cursor to the end of the table
GET PROPERTY OF gs_table 'Range' = gs_range .
GET PROPERTY OF gs_range 'End' = gv_pos .
SET PROPERTY OF gs_range 'Start' = gv_pos .
CALL METHOD OF gs_range 'Select' .
*--Skip some lines
DO 3 TIMES .
CALL METHOD OF gs_selection 'TypeParagraph' .
enddo .
*--Reseting font attributes for ordinary text
SET PROPERTY OF gs_font 'Name' = 'Times New Roman' .
SET PROPERTY OF gs_font 'Size' = '12' .
SET PROPERTY OF gs_font 'Bold' = '0' . "Not bold
SET PROPERTY OF gs_font 'Italic' = '0' . "Not Italic
SET PROPERTY OF gs_font 'Underline' = '0' . "Not underlined
*--Setting paragraph format attribute
SET PROPERTY OF gs_parformat 'Alignment' = '3' . "Justified
*--Indent the paragraph once
GET PROPERTY OF gs_selection 'Paragraphs' = gs_paragraph .
CALL METHOD OF gs_paragraph 'Indent' .
CALL METHOD OF gs_selection 'TypeText'
EXPORTING
#1 = text-002.
FREE OBJECT gs_word.Regards
Raja
‎2005 Aug 16 7:09 AM
Hi,
If I am using the code sample given ,it is displaying only 'This is an OLE example' in a opened document.I am not able to see the tables or any other text.I even tried replacing text symbols.
Waiting for your response.
‎2005 Aug 16 7:53 AM
i am seeing both 'This is an OLE example' and the table.
go into debuggin and see whats the sy-subrc value at the following places.
GET PROPERTY OF gs_actdoc 'Tables' = gs_tables .
GET PROPERTY OF gs_selection 'Range' = gs_range .
*--Adding a table with 3 rows and 2 columns
CALL METHOD OF gs_tables 'Add' = gs_table
EXPORTING
#1 = gs_range " Handle for range entity
#2 = '3' "Number of rows
#3 = '2'. "Number of columns
*--Setting border attribute for the table
GET PROPERTY OF gs_table 'Borders' = gs_table_border .
SET PROPERTY OF gs_table_border 'Enable' = '1' . "With border
Regards
Raja
‎2005 Aug 16 8:11 AM
Hi,
Sy-subrc eq 3.
CALL METHOD OF gs_selection 'TypeText'
EXPORTING
#1 = text-001.
*--Skip some lines
DO 4 TIMES .
sy-subrc eq 4.
CALL METHOD OF gs_selection 'TypeParagraph'
enddo.
GET PROPERTY OF gs_table
'Range' = gs_range .
GET PROPERTY OF gs_range 'End' = gv_pos .
SET PROPERTY OF gs_range 'Start' = gv_pos .
CALL METHOD OF gs_range 'Select' .
Sy-subrc eq 4 after this line.
DO 3 TIMES .
CALL METHOD OF gs_selection 'TypeParagraph' .
Sy-subrc eq 2 here
enddo .
All other places in the coding[including the code you mentioned],sy-subrc is zero.
Could you kndly let me know what I need to change in coding?
Message was edited by: Jayanthi Jayaraman