Re: ole2 and Forms

From: <neil.garside_at_cap.cra.com.au>
Date: Thu, 03 Jun 1999 23:23:28 GMT
Message-ID: <7j72p7$t8k$1_at_nnrp1.deja.com>


Hi Kasia,

The following should work, though it's a bit of a kludge...

I use a function (GetWord97AppObject) that returns a handle to the Word97 object. For example, the following code will call the function and then use the returned value to start a new document based on the specified template:

DECLARE

  lArgs           OLE2.LIST_TYPE;
  objWord97App    OLE2.OBJ_TYPE;
  objWord97Docs   OLE2.OBJ_TYPE;
  objNewWord97Doc OLE2.OBJ_TYPE;

  strTemplateName VARCHAR2(30) := 'C:\Templates\MyTemplate.dot'; BEGIN
  objWord97App := GetWord97AppObject;
  objWord97Docs := OLE2.GET_OBJ_PROPERTY(objWord97App, 'Documents');   lArgs := OLE2.CREATE_ARGLIST;
  OLE2.ADD_ARG(lArgs, strTemplateName);
  objNewWord97Doc := OLE2.INVOKE_OBJ(objWord97Docs, 'Add', lArgs);   OLE2.DESTROY_ARGLIST(lArgs);
END; The function is as follows:

FUNCTION GetWord97AppObject RETURN PLS_INTEGER IS   objNewWord97Doc OLE2.OBJ_TYPE;
  objWord97App OLE2.OBJ_TYPE;
BEGIN

  --The following creates a new Word97 document in an already active
  --instance of Word97. If no active instance is available, an instance
  --will be started.

  objNewWord97Doc := OLE2.CREATE_OBJ('Word.Document.8');   objWord97App := OLE2.GET_OBJ_PROPERTY (objNewWord97Doc, 'Application');
  OLE2.INVOKE(objWord97App, 'Activate');   OLE2.SET_PROPERTY(objWord97App, 'Visible', 1);

  --Need to close the document created...   OLE2.INVOKE(objNewWord97Doc, 'Close');

  --Return the handle to the Word97 application...   RETURN objWord97App;
END; It works, the only side effect of doing it this way is that a document is created each time you call the function and is immediately closed - you sometimes get a 'flash' as the document appears then disappears!

Hope this helps...

Neil W. Garside (Brisbane, Australia)

In article <7j2sih$f6v$1_at_nnrp1.deja.com>,   kasia2011_at_my-deja.com wrote:
> Hi,
>
> some weeks ago, Neil had problems with multiple instances of Word when
> working with ole2. I have the same question ->
>
> Does anyone know how to start an instance of Word97 from Forms (4.5)
> using the OLE2 package so that if an instance of Word97 is already
> running, the Forms application will use this instance?
>  
> For instance, I'm using the following code :
>  
>   application := ole2.CREATE_OBJ('Word.Application');
>  
> This works, but I really don't want to create a new document every
time
> I run this code
>  
> Thanks for help.
>  
> Kasia
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Fri Jun 04 1999 - 01:23:28 CEST

Original text of this message