01-31-2011 12:48 PM
Hi,
I´m creating a function that export an Smartforms to Word.
To do this, I get the texts elements of the Smartforms.
My problem is that I did not find anything about how to config page margin.
I don´t know what's the property to use to config this.
Anybody can help me?
Thanks
01-31-2011 5:26 PM
I think that the best option is to create the Word document directly with OLE objects or using XML namespace of Microsoft.
01-31-2011 5:33 PM
Jorge:
I´m using OLE to create a Word document.
I have already created a document. I just want to configure the page margin.
I do not know what is the property to config this.
I know how to change the font, alignment, create new paragraph... I need just to configure the left page margin.
DATA: gs_word TYPE ole2_object, "OLE object handle
gs_documents TYPE ole2_object, "Documents
gs_actdoc TYPE ole2_object, "Active document
gs_application TYPE ole2_object, "Application
gs_options TYPE ole2_object, "Application options
gs_actwin TYPE ole2_object, "Active window
gs_view TYPE ole2_object, "View
gs_selection TYPE ole2_object, "Selection
gs_font TYPE ole2_object, "Font
gs_parformat TYPE ole2_object, "Paragraph format
gs_inlineshapes TYPE ole2_object, "Image
gs_actpane TYPE ole2_object, "View
gs_border TYPE ole2_object, "Borda
gs_tables TYPE ole2_object, "Tables
gs_table TYPE ole2_object, "One table
gs_table_border TYPE ole2_object, "Table border
gs_cell TYPE ole2_object, "One cell of a table
gs_range_word TYPE ole2_object. "Range handle for various ranges
* Cria objeto Word
CREATE OBJECT gs_word 'WORD.APPLICATION' .
IF sy-subrc NE 0.
MESSAGE s000(su) WITH 'Error while creating OLE object!'.
LEAVE PROGRAM .
ENDIF .
* Seta processo como invisivel
SET PROPERTY OF gs_word 'Visible' = '1' .
* Abre um novo documento
GET PROPERTY OF gs_word 'Documents' = gs_documents .
CALL METHOD OF gs_documents 'Add' .
* Recupera o documento Ativo
GET PROPERTY OF gs_word 'ActiveDocument' = gs_actdoc .
* Recupera controlador da aplicação
GET PROPERTY OF gs_actdoc 'Application' = gs_application .
* Seta Unidade de medida
GET PROPERTY OF gs_application 'Options' = gs_options .
SET PROPERTY OF gs_options 'MeasurementUnit' = '1' . "CM
* Recupera controlador de seleção para controlar a formatação e posição
GET PROPERTY OF gs_application 'Selection' = gs_selection .
GET PROPERTY OF gs_selection 'Font' = gs_font .
GET PROPERTY OF gs_selection 'ParagraphFormat' = gs_parformat .
* Seta atributos da fonte
SET PROPERTY OF gs_font 'Name' = 'Arial' .
SET PROPERTY OF gs_font 'Size' = '11' .
SET PROPERTY OF gs_font 'Bold' = '0' . "Sem negrito
SET PROPERTY OF gs_font 'Italic' = '0' . "Sem Italico
SET PROPERTY OF gs_font 'Underline' = '0' . "Sem sublinhado
CALL METHOD OF gs_selection 'TypeText'
EXPORTING
#1 = 'TEST.
02-07-2011 6:52 PM
I would like to create a footer containing the page number too.
If somebody knows how to do this, please, help me!
Thanks
02-09-2011 6:29 PM
Hi,
To config the page margin with OLE automation.
Go this link
http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-OLEAutomationusing+MS-Word
It explain each statement neatly.
The way of add data and export data to msword.
Margin,border and position all these things explained brifly.
I hope, It will helps to your requirment
02-09-2011 6:38 PM
Hi
Thanks for reply.
I already read that link, but there is nothing about how to configure page margin, explain just how to configure font and alignment.
I have just found the solution.
Is very simply:
CREATE OBJECT gs_word 'WORD.APPLICATION' .
IF sy-subrc NE 0.
MESSAGE s000(su) WITH 'Error while creating OLE object!'.
LEAVE PROGRAM .
ENDIF .
* Set as a visible process
SET PROPERTY OF gs_word 'Visible' = '1' .
* Create a document
GET PROPERTY OF gs_word 'Documents' = gs_documents .
CALL METHOD OF gs_documents 'Add' .
* Get active document
GET PROPERTY OF gs_word 'ActiveDocument' = gs_actdoc .
*-- Config page margin
GET PROPERTY OF gs_actdoc 'PageSetup' = gs_pagesetup.
SET PROPERTY OF gs_pagesetup 'TopMargin' = '3,5 cm'.
SET PROPERTY OF gs_pagesetup 'LeftMargin' = '2,5 cm'.
SET PROPERTY OF gs_pagesetup 'RightMargin' = '1,75 cm'.
Now, I have just need to find a solution to write the page number in the footer.
Thank you for your attention