Re: OLE Automation Forms 4.5 -
Date: 1995/08/03
Message-ID: <3vprri$9i0_at_inet-nntp-gw-1.us.oracle.com>#1/1
> What I would like to do is this:
>
> Link a Word document to a form which, when queried, activates
> the document and puts some data from text items to fields in it.
> Then the user can fill in a few more fields in Word and print
> the document.
>
> I'm totally newbie to OLE. I've tried to read all about it in Forms
> and Word documentation and it seems like that could be possible. The
> problem is that Forms examples "poke" data only to Excel and
> the material on Word that I have doesn't give the slightest hint
> about how to use OLE automation. So if anyone can give a simple
> example solution (or tell with enough authority that it can't be done)
> I'll be most extravagantly grateful.
Hi Pauli.
You surely can control Word 6 from Forms 4.5 via OLE Automation. The Automation interface exported by Word 6 is an interface to WordBasic. Ie, what you can write in your WordBasic code you can write in your Automation controller. Refer to your WordBasic on-line help or manual.
A simple example saving a text field to a temporary file, opening this file with Word, starting the spell checker, saving the file and reading it back into the form is the following:
declare
file text_io.file_type;
fileName varchar2(255) := 'c:\tmp\spell.tmp'; /* Should use Windows API functions for temporary files... */
line varchar2(2000);
argList ole2.list_type;
word ole2.obj_type;
begin
file := text_io.fopen(fileName, 'w');
text_io.put(file, :text);
text_io.fclose(file);
word := ole2.create_obj('Word.Basic');
Word_Basic.FileOpen(word, fileName); Word_Basic.ToolsSpelling(word); Word_Basic.FileSave(word); Word_Basic.AppClose(word);
ole2.release_obj(word);
:text := '';
file := text_io.fopen(fileName, 'r');
loop
text_io.get_line(file, line);
:text := :text || line || chr(13) || chr(10);
end loop;
exception
when no_data_found then
text_io.fclose(file);
/* And remove temporary file... */
end;
This code uses the following package:
package body Word_Basic is
procedure FileOpen(this ole2.obj_type, fileName varchar2) is
argList ole2.list_type;
begin
argList := ole2.create_arglist;
ole2.add_arg(argList, fileName); ole2.invoke(this, 'FileOpen', argList); ole2.destroy_arglist(argList);
end;
procedure ToolsSpelling(this ole2.obj_type) is
begin
ole2.invoke(this, 'ToolsSpelling');
end;
procedure FileSave(this ole2.obj_type) is
begin
ole2.invoke(this, 'FileSave');
end;
procedure AppClose(this ole2.obj_type) is
begin
ole2.invoke(this, 'AppClose');
end;
end;
Hope this helps,
cheers,
Finn
Finn Ellebaek Nielsen Phone: +45 44 80 80 80 Consultant Phone direct: +45 44 80 81 11 Oracle Danmark A/S Fax: +45 44 80 80 93 Lautrupbjerg 2-6 DK-2750 Ballerup Oracle e-mail: fellebuk.dk Denmark Internet e-mail: fellebuk_at_dk.oracle.com -------------------------------------------------------------------------------- "Life is a beach and then you dive" "Divers do it deeper"Received on Thu Aug 03 1995 - 00:00:00 CEST