Adding a new line in a word document using ole2 [message #274963] |
Wed, 17 October 2007 23:18 |
|
sasipalarivattom
Messages: 121 Registered: June 2007 Location: Cochin ( INDIA )
|
Senior Member |
|
|
Hi dear..
I have created a form from which i am creating a word document.
Actually what I have to do is to export the records in my table to a word file.
I put a button in the canvas and wrote the code in WHEN-BUTTON-PRESSED trigger.
Now the problem is that only the last record is printed in the word document.
I assume that all records are printed in the same location of the word document and theirfore only the last record is visible.
I search the forum for any help but i didn't get a code to print a new line in the document.
I shall paste the code here...
DECLARE
MyApplication ole2.obj_Type;
Workbooks ole2.obj_Type;
Workbook ole2.obj_Type;
MyDocuments ole2.obj_Type;
MySelection ole2.obj_Type;
MyDocument ole2.obj_Type;
args ole2.List_Type;
CURSOR c1 IS
SELECT Rpad(ROWNUM,30)
||Rpad(YearCode,30)
||Rpad(comp_Code,30)
||Rpad(div_Code,30) txt
FROM prtJobhd
WHERE ROWNUM < 5;
BEGIN
MyApplication := ole2.Create_obj('Word.Application');
ole2.Set_Property(MyApplication,'Visible',1);
MyDocuments := ole2.Get_obj_Property(MyApplication,'Documents');
MyDocument := ole2.Invoke_obj(MyDocuments,'Add');
MySelection := ole2.Get_obj_Property(MyApplication,'Selection');
FOR Counter IN c1 LOOP
ole2.Set_Property(MySelection,'Text',Counter.txt);
END LOOP;
args := ole2.Create_argList;
ole2.Add_arg(args,'D:\VPURI\DOCS\EXAMPLE.DOC');
ole2.Invoke(MyDocument,'SaveAs',args);
ole2.Destroy_argList(args);
ole2.Release_obj(MySelection);
ole2.Release_obj(MyDocument);
ole2.Release_obj(MyDocuments);
ole2.Release_obj(MyApplication);
EXCEPTION
WHEN OTHERS THEN
Message(SQLERRM);
Message(SQLERRM);
END;
Please help me...
Upd-mod: Please use 'code' tags.
[Updated on: Wed, 17 October 2007 23:30] by Moderator Report message to a moderator
|
|
|
|
|