Home » Developer & Programmer » Forms » Adding a new line in a word document using ole2 (New line in word document through form.)
Adding a new line in a word document using ole2 [message #274963] Wed, 17 October 2007 23:18 Go to next message
sasipalarivattom
Messages: 118
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

Re: Adding a new line in a word document using ole2 [message #274966 is a reply to message #274963] Wed, 17 October 2007 23:37 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
I did a search for "ole2.Set_Property 'Word.Application'" and found a few threads which have code similar to yours.

Verify that you are in 'insert' not 'overtype' mode. I think the command has the parameter value 'add'. Its in one of those threads.

David
Re: Adding a new line in a word document using ole2 [message #275008 is a reply to message #274966] Thu, 18 October 2007 01:56 Go to previous message
sasipalarivattom
Messages: 118
Registered: June 2007
Location: Cochin ( INDIA )
Senior Member

Sorry Mr David.
I search again and again but didn't get the solution for my problem.
I saw someone posted similar questian but was answered by noone.
...
Previous Topic: manage a word document with forms 6i
Next Topic: DATA INSERT PROBLEM
Goto Forum:
  


Current Time: Sat Dec 10 06:52:33 CST 2016

Total time taken to generate the page: 0.08829 seconds