Home » Developer & Programmer » Forms » ole2 package (Forms 6i)
ole2 package [message #622114] Thu, 21 August 2014 03:25 Go to next message
rudeto
Messages: 3
Registered: July 2014
Junior Member
Hi all,

Please give me an example how to add FormFields in Word with some values using ole2 package.

Thanx in advance.
Re: ole2 package [message #622149 is a reply to message #622114] Thu, 21 August 2014 08:24 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
There are a lot of OLE2 examples and tutorials on the Internet. What have you tried...can you give us a code sample?

Craig...

[Updated on: Thu, 21 August 2014 08:25]

Report message to a moderator

Re: ole2 package [message #622185 is a reply to message #622149] Fri, 22 August 2014 06:39 Go to previous messageGo to next message
rudeto
Messages: 3
Registered: July 2014
Junior Member
Hi Craig,

This is part of code for Forms6i :

declare
hApplication OLE2.OBJ_TYPE;
hDocuments OLE2.OBJ_TYPE;
hDocument OLE2.OBJ_TYPE;
hSelection OLE2.OBJ_TYPE;
hParagraphFormat OLE2.OBJ_TYPE;
hParagraph OLE2.OBJ_TYPE;
hRange OLE2.OBJ_TYPE;
hRange1 OLE2.OBJ_TYPE;
hFont OLE2.OBJ_TYPE;
hTables OLE2.OBJ_TYPE;
hTable OLE2.OBJ_TYPE;
hFields OLE2.OBJ_TYPE;
formfield OLE2.OBJ_TYPE;
formfields OLE2.OBJ_TYPE;

args OLE2.LIST_TYPE;

wdAlignParagraphLeft CONSTANT number(3) := 0; --Default
wdword9tablebehavior CONSTANT NUMBER (5) := 1;
wdautofitfixed CONSTANT NUMBER (5) := 0;
---- wdUnits Class members
wdcharacter CONSTANT NUMBER (5) := 1;
wdmove CONSTANT NUMBER (5) := 0; --Default

--wdBorderType Class members
wdborderleft CONSTANT NUMBER := -2;
wdborderright CONSTANT NUMBER := -4;
wdbordertop CONSTANT NUMBER := -1;
wdborderbottom CONSTANT NUMBER := -3;
--WdLineStyle Class member
wdlinestylenone CONSTANT NUMBER := 0;
num number;
wdFieldNumPages CONSTANT number(3) := 26;

BEGIN
hApplication:=OLE2.CREATE_OBJ('Word.Application');


hDocuments := OLE2.GET_OBJ_PROPERTY(hApplication, 'Documents');
hDocument := OLE2.INVOKE_OBJ(hDocuments, 'Add');
hSelection := OLE2.GET_OBJ_PROPERTY(hApplication, 'Selection');
hFont := OLE2.GET_OBJ_PROPERTY(hSelection, 'Font');
OLE2.SET_PROPERTY(hFont, 'Name', 'Calibri');
OLE2.SET_PROPERTY(hFont, 'Size', 11);
OLE2.SET_PROPERTY(hFont, 'Bold', FALSE );
OLE2.INVOKE(hSelection, 'TypeParagraph');
hParagraphFormat := OLE2.GET_OBJ_PROPERTY(hSelection, 'ParagraphFormat');
OLE2.SET_PROPERTY(hParagraphFormat, 'Alignment', wdAlignParagraphLeft);
OLE2.RELEASE_OBJ(hParagraphFormat);
args := OLE2.CREATE_ARGLIST;

OLE2.ADD_ARG(args, 'Hello World for TypeText');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);

args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'Hello World for Formfields'); -- with this part of code I am trying to make FormField but without success
OLE2.INVOKE(hSelection, 'Formfields', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.INVOKE(hSelection, 'TypeParagraph');


OLE2.SET_PROPERTY(hApplication, 'Visible', 1);


ole2.RELEASE_OBJ (happlication);
ole2.RELEASE_OBJ (hdocuments);
ole2.RELEASE_OBJ (hdocument);
ole2.RELEASE_OBJ (hfont);
ole2.RELEASE_OBJ (hparagraphformat);
ole2.RELEASE_OBJ (htables);
ole2.RELEASE_OBJ (hrange);
return;
END;

I need FormField in Word document because I want to protected some fields and other part of document is not protected.
I tried something with word Macros , and text fields works fine, but FormFiled have errors.

If you have some ideas please send me your code.
Thanx in advance.
Rudeto
Re: ole2 package [message #622361 is a reply to message #622185] Mon, 25 August 2014 12:51 Go to previous message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Sorry, I've never written to a FormField in a Word document using OLE2 or WebUtil. I do know that it is Case Sensative so make sure 'Formsfields' is not 'FormFields'. The other suggestion I would make is to create a Macro to do what you want in Word. Then edit your macro to see how Word references your 'Formfields' and use the same name in your Form code.

Hope this helps.
Craig...
Previous Topic: Is this is a bug of Oracle?!!!
Next Topic: error ROW_NUMBER() in form
Goto Forum:
  


Current Time: Fri Apr 26 08:22:58 CDT 2024