Home » Developer & Programmer » Forms » webutil : Open Word.Application (10g)
webutil : Open Word.Application [message #305969] Wed, 12 March 2008 07:57 Go to next message
vikingo98
Messages: 5
Registered: March 2008
Location: mallorca
Junior Member
Hello, I want to open a word from a field of a forms, that me get the field content, to be able to modify the text of the word and on having closed the word, put the content of the word in the field.

DECLARE
app CLIENT_OLE2.OBJ_TYPE;
docs CLIENT_OLE2.OBJ_TYPE;
doc CLIENT_OLE2.OBJ_TYPE;
selection CLIENT_OLE2.OBJ_TYPE;
args CLIENT_OLE2.LIST_TYPE;
sel_text varchar2(4000);

BEGIN

app := CLIENT_OLE2.CREATE_OBJ('Word.Application');
CLIENT_OLE2.SET_PROPERTY(app,'Visible',1);
docs := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Documents');
doc := CLIENT_OLE2.INVOKE_OBJ(docs, 'add');
selection := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Selection');
doc := CLIENT_OLE2.GET_OBJ_PROPERTY(doc, 'ActiveDocument');
CLIENT_OLE2.SET_PROPERTY(selection, 'Text', :CD_OTR.DESCDDIDI1);
--**************************
--*************************
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(args, 'c:\example.doc');
CLIENT_OLE2.INVOKE(doc, 'SaveAs', args);
CLIENT_OLE2.DESTROY_ARGLIST(args);
-- close example.tmp
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(args, 0);
CLIENT_OLE2.INVOKE(doc, 'Close', args);
CLIENT_OLE2.DESTROY_ARGLIST(args);
CLIENT_OLE2.RELEASE_OBJ(selection);
CLIENT_OLE2.RELEASE_OBJ(doc);
CLIENT_OLE2.RELEASE_OBJ(docs);
-- exit MSWord
CLIENT_OLE2.INVOKE(app,'Quit');
END;


This code, open a word from a field of a forms, that me get the field content, to be able to modify the word and on having closed the word, BUT not put the content of the word in the field.


Can you help-me???

Sorry for my English, I'm spanish.
Re: webutil : Open Word.Application [message #307444 is a reply to message #305969] Tue, 18 March 2008 22:43 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Look at:
Ole2 data from database to word document
http://www.orafaq.com/forum/t/80617/0/unread/67467/#msg_233229

Did this help?

David
Re: webutil : Open Word.Application [message #342108 is a reply to message #305969] Thu, 21 August 2008 06:36 Go to previous messageGo to next message
vikingo98
Messages: 5
Registered: March 2008
Location: mallorca
Junior Member
Its ok, thanks
Re: webutil : Open Word.Application [message #342113 is a reply to message #305969] Thu, 21 August 2008 06:47 Go to previous messageGo to next message
vikingo98
Messages: 5
Registered: March 2008
Location: mallorca
Junior Member
The application available to me, I generates a word from the data that you step and use of a template. What I realize now is that the word I want it generates is write-protected.
It's possible?

I test with this code, (line red) but its bad.

Thanks

PROCEDURE worddoc IS
BEGIN
DECLARE
app CLIENT_OLE2.OBJ_TYPE;
docs CLIENT_OLE2.OBJ_TYPE;
doc CLIENT_OLE2.OBJ_TYPE;
selection CLIENT_OLE2.OBJ_TYPE;
args CLIENT_OLE2.LIST_TYPE;
BEGIN
-- create a new document
app := CLIENT_OLE2.CREATE_OBJ('Word.Application');
CLIENT_OLE2.SET_PROPERTY(app,'Visible',0);

docs := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Documents');
doc := CLIENT_OLE2.INVOKE_OBJ(docs, 'add');

selection := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Selection');

-- insert data into new document from long item
CLIENT_OLE2.SET_PROPERTY(selection, 'Text', :txt_comment);

-- save document as example.doc
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(args, :txt_path);
CLIENT_OLE2.INVOKE(doc, 'SaveAs', args);
CLIENT_OLE2.DESTROY_ARGLIST(args);

-- close example.doc
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(args, 0);
Client_OLE2.INVOKE (doc,'ProtectedForForms',args);
CLIENT_OLE2.INVOKE(doc, 'Close', args);
CLIENT_OLE2.DESTROY_ARGLIST(args);

CLIENT_OLE2.RELEASE_OBJ(selection);
CLIENT_OLE2.RELEASE_OBJ(doc);
CLIENT_OLE2.RELEASE_OBJ(docs);

-- exit MSWord
CLIENT_OLE2.INVOKE(app,'Quit');
END;
END;

[Updated on: Thu, 21 August 2008 06:53]

Report message to a moderator

Re: webutil : Open Word.Application [message #342268 is a reply to message #342113] Thu, 21 August 2008 18:29 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Please confirm: (1) the word document is being created but is write-protected and you do NOT want this behaviour or (2) AFTER the document is created you WANT to make it write-protected.

David
Re: webutil : Open Word.Application [message #342356 is a reply to message #305969] Fri, 22 August 2008 02:07 Go to previous messageGo to next message
vikingo98
Messages: 5
Registered: March 2008
Location: mallorca
Junior Member
hello, AFTER the document is created I WANT to make it write-protected.

Thanks.
Re: webutil : Open Word.Application [message #342859 is a reply to message #305969] Mon, 25 August 2008 06:28 Go to previous message
vikingo98
Messages: 5
Registered: March 2008
Location: mallorca
Junior Member
I have this macro:

ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
End Sub

and this code:


DECLARE
app CLIENT_OLE2.OBJ_TYPE;
docs CLIENT_OLE2.OBJ_TYPE;
doc CLIENT_OLE2.OBJ_TYPE;
selection CLIENT_OLE2.OBJ_TYPE;
args CLIENT_OLE2.LIST_TYPE;
BEGIN
-- crear Nuevo documento
app := CLIENT_OLE2.CREATE_OBJ('Word.Application');
CLIENT_OLE2.SET_PROPERTY(app,'Visible',1);
docs := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Documents');
doc := CLIENT_OLE2.INVOKE_OBJ(docs, 'add');
selection := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Selection');
-- insertamos un texto dentro del Nuevo documento
CLIENT_OLE2.SET_PROPERTY(selection, 'Text', 'this is a test message');
-- guardamos el documento
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(args, 'c:\example.doc');
CLIENT_OLE2.INVOKE(doc, 'SaveAs', args);
CLIENT_OLE2.DESTROY_ARGLIST(args);
-- close el documento
args := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(args, 0);
CLIENT_OLE2.INVOKE(doc, 'Protect', args);

CLIENT_OLE2.ADD_ARG(args, 0);
CLIENT_OLE2.INVOKE(doc, 'Close', args);
CLIENT_OLE2.DESTROY_ARGLIST(args);
CLIENT_OLE2.RELEASE_OBJ(selection);
CLIENT_OLE2.RELEASE_OBJ(doc);
CLIENT_OLE2.RELEASE_OBJ(docs);
-- salimos de MSWord
CLIENT_OLE2.INVOKE(app,'Quit');
END;
Previous Topic: webutil
Next Topic: displaying multiple rows retured from a query
Goto Forum:
  


Current Time: Sat Dec 10 05:28:10 CST 2016

Total time taken to generate the page: 0.04616 seconds