Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Word commandBar from OracleForms 6i with OLE2

Status
Not open for further replies.

ricaforrica

Programmer
Jun 30, 2005
65
PT
Greetings!

I'm currently working on a healthcare solution developed in Oracle Forms. Imagine a doctor assisting his patient: he uses our "doctor desktop" which provides all kind of information about the patient and his' clinical episodes. One of these features is the generation of a MSWord clinical report for the current patient, based on a template.

My goal is to create a commandbar, visible when the report is open, which will present other pending reports of the current patient.

So, I'm using OLE2 in order to achieve this objective. The code is the following:

DECLARE
-- Declare the OLE objects
MyApplication OLE2.OBJ_TYPE;
MyDocuments OLE2.OBJ_TYPE;
MyDocument OLE2.OBJ_TYPE;
MyCommandBars OLE2.OBJ_TYPE;
MyReportBar OLE2.OBJ_TYPE;
MyControls OLE2.OBJ_TYPE;

-- Declare handle to the OLE argument list
args OLE2.LIST_TYPE;
arg OLE2.LIST_TYPE;
arg2 OLE2.LIST_TYPE;

BEGIN
-- Create the Word.Application object
MyApplication := OLE2.CREATE_OBJ('Word.Application');

-- get a handle on Documents collection
MyDocuments:= OLE2.GET_OBJ_PROPERTY(MyApplication, 'Documents');

-- Add a new document to the Documents collection
Mydocument := OLE2.INVOKE_OBJ(MyDocuments, 'Add');

-- Get a handle on CommandBars object
MyCommandBars:=OLE2.GET_OBJ_PROPERTY(MyApplication, 'CommandBars');

arg := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(arg, 'Relatórios');
OLE2.ADD_ARG(arg, 'MsoBarPosition.msoBarFloating');
OLE2.ADD_ARG(arg, 'False');
OLE2.ADD_ARG(arg, 'True');
OLE2.INVOKE(MyCommandBars, 'Add', arg);
OLE2.DESTROY_ARGLIST(arg);

-- Save the document to the filesystem as EXAMPLE.DOC
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'C:\EXAMPLE.DOC');
OLE2.INVOKE(MyDocument, 'SaveAs', args);
OLE2.DESTROY_ARGLIST(args);

-- Close the document
OLE2.INVOKE(MyDocument, 'Close');

-- Release the OLE objects

OLE2.RELEASE_OBJ(MyCommandBars);
OLE2.RELEASE_OBJ(MySelection);
OLE2.RELEASE_OBJ(MyDocument);
OLE2.RELEASE_OBJ(MyDocuments);
OLE2.RELEASE_OBJ(MyApplication);
END;

This code is working well: it creates a command bar. But now I want to add buttons or links to commandbar! I tried doing this:

use
MyReportBar:=OLE2.INVOKE_OBJ(MyCommandBars, 'Add', arg);
instead of
OLE2.INVOKE(MyCommandBars, 'Add', arg);
so that I could get a handle on my new bar and then add a button to the controls with:

-- Get a handle on Controls object
MyControls:=OLE2.GET_OBJ_PROPERTY(MyReportBar, 'Controls');
arg2 := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(arg2, 'msoControlButton');
OLE2.Invoke(MyControls, 'add', arg2);
OLE2.DESTROY_ARGLIST(arg2);

Unfortunately, MyReportBar:=OLE2.INVOKE_OBJ(MyCommandBars, 'Add', arg); didn't work! I got an exception (ORA-305500)...

Can anyone help me with this issue? Or suggest any alternative solution?

Thanks in advance,

Ricardo Pinto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top