Home » Developer & Programmer » Forms » Ole2 data from database to word document
Ole2 data from database to word document [message #233229] Wed, 25 April 2007 04:43 Go to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi,


I am porting data from database to word document.Initially i am creating the table using the following code:

hSelection := OLE2.GET_OBJ_PROPERTY(hApplication, 'Selection');
hTables := OLE2.GET_OBJ_PROPERTY(hDocument , 'Tables' );
hRange := OLE2.GET_OBJ_PROPERTY(hSelection, 'Range');
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG_OBJ(args, hRange); --Range
OLE2.ADD_ARG(args, 26); --NumRows
OLE2.ADD_ARG(args, 4); --NumColumns
OLE2.ADD_ARG(args, wdWord9TableBehavior); --DefaultTableBehavior
OLE2.ADD_ARG(args, wdAutoFitContent); --AutoFitBehavior
hTable := OLE2.INVOKE_OBJ(hTables, 'Add', args);

But i want to change the columnwidth.
As you see above i have 4 columns, in that first column should be double than other column.

please send me the peice of code to change th ewidth of column in word document.

thanks,
Srinivas
Re: Ole2 data from database to word document [message #233567 is a reply to message #233229] Thu, 26 April 2007 11:18 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
I think nobody has answer for this. Embarassed
Re: Ole2 data from database to word document [message #233942 is a reply to message #233229] Sat, 28 April 2007 07:11 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi ,

I got the solution after two today's of R&D.Here is the full code.I hope this will be helpfull.

I created the code in a procedure in program units and calling
in forms:

Here is the whole Code:
PROCEDURE Pr_Ole2_Word_Doc IS
V_Application Ole2.Obj_Type;
V_Documents Ole2.Obj_Type;
V_Document Ole2.Obj_Type;
V_Selection Ole2.Obj_Type;
V_Range Ole2.Obj_Type;
V_Tables Ole2.Obj_Type;
V_Table Ole2.Obj_Type;
V_Cells Ole2.Obj_Type;
V_Rows Ole2.Obj_Type;
V_Column Ole2.Obj_Type;
V_Shading Ole2.Obj_Type;
V_ParagraphFormat Ole2.Obj_Type;
V_Font Ole2.Obj_Type;
V_Window Ole2.Obj_Type;
V_Pane Ole2.Obj_Type;
V_View Ole2.Obj_Type;
V_Fields Ole2.Obj_Type;
V_Args Ole2.List_Type;
V_Pagesetup Ole2.Obj_Type;
V_InlineShapes Ole2.Obj_Type;
V_CellColumn CONSTANT NUMBER(3) := 0;
WdSeekCurrentPageHeader CONSTANT NUMBER(3) := 9;
WdSeekCurrentPageFooter CONSTANT NUMBER(3) := 10;
WdSeekMainDocument CONSTANT NUMBER(3) := 0;
WdFieldPage CONSTANT NUMBER(3) := 33;
WdFieldNumPages CONSTANT NUMBER(3) := 26;
WdPageBreak CONSTANT NUMBER(3) := 7;
WdStory CONSTANT NUMBER(3) := 6;
---- wdDefaultTableBehavior Class members
WdWord8TableBehavior CONSTANT NUMBER(5) := 0; --Default
WdWord9TableBehavior CONSTANT NUMBER(5) := 1;

---- wdAutoFitBehavior Class members
---- (only works when DefaultTableBehavior = wdWord9TableBehavior)
WdAutoFitContent CONSTANT NUMBER(5) := 1;
WdAutoFitFixed CONSTANT NUMBER(5) := 0;
WdAutoFitWindow CONSTANT NUMBER(5) := 2;

---- wdUnits Class members
WdCell CONSTANT NUMBER(5) := 12;
WdCharacter CONSTANT NUMBER(5) := 1; --Default
WdWord CONSTANT NUMBER(5) := 2;
WdSentence CONSTANT NUMBER(5) := 3;
WdLine CONSTANT NUMBER(5) := 5;

---- wdMovementType Class members
WdExtend CONSTANT NUMBER(5) := 1;
WdMove CONSTANT NUMBER(5) := 0; --Default

---- WdParagraphAlignment Class members
WdAlignParagraphCenter CONSTANT NUMBER(5) := 1;
WdAlignParagraphLeft CONSTANT NUMBER(5) := 0;
WdAlignParagraphRight CONSTANT NUMBER(5) := 2;

V_Footer VARCHAR2(1000);
V_Cnt NUMBER := 0;
V_Cnt_Brk NUMBER := 1;
V_Brk NUMBER := 0;
V_File_Name VARCHAR2(100);
V_Print_Logo VARCHAR2(100);
Err_code BINARY_INTEGER;
Err_text VARCHAR2(255);
CURSOR c1 IS
SELECT Line_No , Benefit_Line , Cost , Guaranteed , Expected , Row_type
FROM EMP
WHERE Line_No >= 2
ORDER BY Line_No;

BEGIN
----Invoke A word document
V_Application := Ole2.Create_Obj('Word.Application');
Ole2.Set_Property(V_Application, 'Visible', 1);

V_Documents := Ole2.Get_Obj_Property(V_Application, 'Documents');
V_Document := Ole2.Invoke_Obj(V_Documents,'Add');

----Get window pane to insert into Header and Footer
V_Window := Ole2.Get_Obj_Property(V_Application, 'ActiveWindow');
V_Pane := Ole2.Get_Obj_Property(V_Window, 'ActivePane' );
V_View := Ole2.Get_Obj_Property(V_Pane, 'View' );

----Header Section
Ole2.Set_Property(V_View, 'SeekView', WdSeekCurrentPageHeader);
V_Selection := Ole2.Get_Obj_Property(V_Application, 'Selection');

SELECT Benefit_Line , Cost INTO V_Print_Logo , V_File_Name
FROM EMP
WHERE Line_No = 1 ;

----Insert image in Header Section
IF V_Print_Logo = 'PRINT_LOGO=Y' THEN
V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', WdAlignParagraphRight);
Ole2.Release_Obj (V_ParagraphFormat);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, 'C:\ss1wpp\Oracle\Images\cambridge.jpg');
InlineShapes := Ole2.Get_Obj_Property(V_Selection,'InlineShapes');
Ole2.Invoke(InlineShapes,'AddPicture',V_Args);
Ole2.Destroy_Arglist(V_Args);
ELSE
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
END IF;

----- Footer Section
SELECT Benefit_Line INTO V_Footer
FROM EMP
WHERE Line_No = ( SELECT MAX(line_no) FROM EMP);
V_File_Name:= 'C:\Proposals\'||:Global.User_Name||'\'||V_File_Name||'.doc';

Ole2.Set_Property(V_View, 'SeekView', wdSeekCurrentPageFooter);
V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphleft);
Ole2.Release_Obj (V_ParagraphFormat);

V_Fields := Ole2.Get_Obj_Property(V_Selection, 'Fields');
V_Font := Ole2.Get_Obj_Property(V_Selection, 'Font');
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 10);
Ole2.Set_Property(V_Font, 'Bold', FALSE );
Ole2.Set_Property(V_Font, 'Italic', TRUE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg (V_Args, V_Footer);
Ole2.Invoke (V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

Ole2.Set_Property(V_View, 'SeekView', wdSeekMainDocument);
Ole2.Release_Obj (V_View);
Ole2.Release_Obj (V_Pane);
Ole2.Release_Obj (V_Window);

----end of footer and header

----Create Table
V_Selection := Ole2.Get_Obj_Property(V_Application, 'Selection');
V_Tables := Ole2.Get_Obj_Property(V_Document , 'Tables' );
V_Pagesetup := Ole2.Get_Obj_Property(V_Document , 'PageSetup' );
V_Range := Ole2.Get_Obj_Property(V_Selection, 'Range');
Ole2.Set_Property(V_Pagesetup,'leftmargin',65);
Ole2.Set_Property(V_Pagesetup,'rightmargin',51);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg_OBJ(V_Args, V_Range); --Range
Ole2.Add_Arg(V_Args, 26); --NumRows
Ole2.Add_Arg(V_Args, 4); --NumColumns
Ole2.Add_Arg(V_Args, wdWord8TableBehavior); --DefaultTableBehavior
Ole2.Add_Arg(V_Args, wdAutoFitContent); --AutoFitBehavior
V_Table := Ole2.Invoke_OBJ(V_Tables, 'Add', V_Args);

Ole2.Destroy_Arglist(V_Args);
Ole2.Release_Obj(V_Table);
Ole2.Release_Obj(V_Range);
Ole2.Release_Obj(V_Pagesetup);
Ole2.Release_Obj(V_Tables);
----End Of Table


----After Creating Table Set the column width
V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 200);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 105);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 105);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 105);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

----End For column width

SELECT MAX(line_No) INTO V_Cnt
FROM EMP;

SELECT COUNT(1) INTO V_Brk
FROM EMP
WHERE Benefit_Line Like 'PAGE%';

FOR i IN C1 LOOP

IF i.Line_No = V_Cnt THEN
Null;
ELSIF i.Benefit_Line = 'PAGEBREAK' THEN
IF V_Cnt_Brk < V_Brk THEN
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdPageBreak);
Ole2.Invoke(V_Selection, 'InsertBreak', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Selection := Ole2.Get_Obj_Property(V_Application, 'Selection');
V_Tables := Ole2.Get_Obj_Property(V_Document , 'Tables' );
V_Range := Ole2.Get_Obj_Property(V_Selection, 'Range');
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg_OBJ(V_Args, V_Range); --Range
Ole2.Add_Arg(V_Args, 26); --NumRows
Ole2.Add_Arg(V_Args, 4); --NumColumns
Ole2.Add_Arg(V_Args, wdWord8TableBehavior); --DefaultTableBehavior
Ole2.Add_Arg(V_Args, wdAutoFitContent); --AutoFitBehavior
V_Table := Ole2.Invoke_OBJ(V_Tables, 'Add', V_Args);
Ole2.Destroy_Arglist(V_Args);
Ole2.Release_Obj(V_Table);
Ole2.Release_Obj(V_Range);
Ole2.Release_Obj(V_Tables);
V_Cnt_Brk := V_Cnt_Brk + 1;

V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 200);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke (V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke (V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 105);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke (V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke (V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 105);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke (V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke (V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Column := Ole2.Get_Obj_Property(V_Selection, 'Columns');
Ole2.Set_Property(V_Column, 'Width', 105);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, '');
Ole2.Invoke (V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke (V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);
END IF;
ELSIF i.Row_Type LIKE 'M%B' THEN
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCharacter); --Unit
Ole2.Add_Arg(V_Args, 4); --Count
Ole2.Add_Arg(V_Args, wdExtend); --Extend
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Cells := Ole2.Get_Obj_Property(V_Selection, 'Cells');
Ole2.Invoke(V_Cells, 'Merge');

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphCenter);
IF i.Benefit_Line LIKE 'Date%' THEN
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 12);
Ole2.Set_Property(V_Font, 'Bold', TRUE );
ELSE
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 14);
Ole2.Set_Property(V_Font, 'Bold', TRUE );
END IF;
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Benefit_Line);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);
ELSIF i.Row_Type = 'M' THEN
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCharacter); --Unit
Ole2.Add_Arg(V_Args, 4); --Count
Ole2.Add_Arg(V_Args, wdExtend); --Extend
Ole2.Invoke (V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Cells := Ole2.Get_Obj_Property(V_Selection, 'Cells');
Ole2.Invoke(V_Cells, 'Merge');

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphCenter);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Benefit_Line);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);
ELSIF i.Row_Type IS NULL THEN
V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphleft);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', FALSE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Benefit_Line);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphright);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', FALSE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Cost);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphright);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', FALSE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Guaranteed);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphright);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', FALSE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args,i.Expected);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);


V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);
ELSIF i.Row_Type = 'B' then
V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphleft);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', TRUE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Benefit_Line);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphright);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', TRUE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Cost);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphright);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', TRUE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, i.Guaranteed);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_ParagraphFormat := Ole2.Get_Obj_Property(V_Selection, 'ParagraphFormat');
Ole2.Set_Property(V_ParagraphFormat, 'Alignment', wdAlignParagraphright);
Ole2.Set_Property(V_Font, 'Name', 'Times New Roman');
Ole2.Set_Property(V_Font, 'Size', 11);
Ole2.Set_Property(V_Font, 'Bold', TRUE );
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args,i.Expected);
Ole2.Invoke(V_Selection, 'TypeText', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdCell);
Ole2.Add_Arg(V_Args, 1);
Ole2.Add_Arg(V_Args, wdMove);
Ole2.Invoke(V_Selection, 'MoveRight', V_Args);
Ole2.Destroy_Arglist(V_Args);
END IF;
END LOOP;
V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, wdStory);
Ole2.Invoke(V_Selection, 'HomeKey', V_Args);
Ole2.Destroy_Arglist(V_Args);

V_Args := Ole2.Create_Arglist;
Ole2.Add_Arg(V_Args, V_File_Name);
Ole2.Invoke(V_Document, 'SaveAs', V_Args);
Ole2.Destroy_Arglist(V_Args);

Ole2.Release_Obj(V_Column);
Ole2.Release_Obj(V_Font);
Ole2.Release_Obj(V_ParagraphFormat);
Ole2.Release_Obj(V_Selection);
Ole2.Release_Obj(V_Document);
Ole2.Release_Obj(V_Documents);
Ole2.Release_Obj(V_Application);
EXCEPTION
WHEN Ole2.OLE_ERROR THEN
message('Error');
message('Error');
WHEN others THEN
message('Error');
message('Error');
END;

Full happy.....

Re: Ole2 data from database to word document [message #482347 is a reply to message #233942] Thu, 11 November 2010 02:13 Go to previous messageGo to next message
halalimo
Messages: 3
Registered: November 2010
Junior Member
hi
can you send emp table that you use it in procedure
Re: Ole2 data from database to word document [message #482357 is a reply to message #482347] Thu, 11 November 2010 02:59 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
As this is not the standard EMP table, we can't help but if you are lucky OP still hear and remember what was his (example) table.
I think the best way for you is to create your own, the following statement gives you the column you must have:
SELECT Line_No , Benefit_Line , Cost , Guaranteed , Expected , Row_type
FROM EMP 


Regards
Michel
Re: Ole2 data from database to word document [message #482590 is a reply to message #482357] Sat, 13 November 2010 03:14 Go to previous messageGo to next message
NaeemAlsaadi
Messages: 20
Registered: November 2010
Location: Oman
Junior Member
thanks a lot for this example
i will try - i am looking for export date from form bulder to excel do this will be usefull for me
Re: Ole2 data from database to word document [message #483671 is a reply to message #482590] Wed, 24 November 2010 01:35 Go to previous message
halalimo
Messages: 3
Registered: November 2010
Junior Member
hi
i can't set font size for arabic language
please help me
thanks
Previous Topic: Forms 10g
Next Topic: Download / upload to excel through forms 6i in oracle apps
Goto Forum:
  


Current Time: Thu Dec 26 15:16:01 CST 2024