Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Viewing Word documents from VFP
Message
De
21/06/2000 03:30:56
 
 
À
19/06/2000 15:24:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00376075
Message ID:
00382566
Vues:
52
Same:

This is also a continuation of the previous message. Save this file to
GenOleAppProcs.prg

*-------------------------------------------------------------------------------
*
* GenOleAppProcs
* --------------
*
* This library contains all the functions necessary to connect to an
* OLE Application Server.
*
* Contents : CreateNewOleInstance
* GetCurrentOleInstance
* IsOleAppRunning
* LaunchOleApp
*
* Notes : DLLs are not required.
*------------------------------------------------------------------------------
#INCLUDE constants.h

*==============================================================================
* CreateNewOleInstance
* --------------------
*
* Purpose.......: Creates a new instance of an OLE Application Server.
* Author........: Daniel Rouleau - Metro Information Services
* email: Daniel.Rouleau@MetroIs.com
* Last Revision.: 19998-08-27
*
* Syntax........: CreateNewOleInstance( tcApplication )
* Returns.......: object or null
* Arguments.....: tcApplication
* Specifies the name of the OLE Application.
*
* Remarks.......: CreateNewOleInstance returns a reference to the just created
** OLE Application Server or NULL if the creation failed.
*==============================================================================
FUNCTION CreateNewOleInstance
LPARAMETERS tcApplication

LOCAL loRetVal && Value returned by this function.
LOCAL lcApplication && Upper case version of tcApplication.
LOCAL loOleApp && OLE automation object.

loRetVal = _SCREEN && To ensure loRetVal is an object.
loRetVal = .NULL.
lcApplication = IIF(TYPE("tcApplication") == "C", UPPER(ALLTRIM(tcApplication)), "")
loOleApp = .F.

* --------------------------
* -- Create an instance of
* -- the appropriate class.
* --------------------------
DO CASE
CASE lcApplication = "WORD"
loOleApp = CREATEOBJECT("clOleWord")
IF TYPE("loOleApp") == "O" AND NOT ISNULL(loOleApp)
loRetVal = loOleApp.CreateNewInstance()
IF (TYPE("loRetVal") == "O") AND NOT ISNULL(loRetVal)
loRetVal.WindowState = wdWindowStateMinimize
loRetVal.Visible = wdTrue
ENDIF
ENDIF
ENDCASE

loOleApp = .NULL.
RELEASE loOleApp
CLEAR CLASS loOleApp


RETURN ( loRetVal )

*==============================================================================
* GetCurrentOleInstance
* ---------------------
*
* Purpose.......: Returns a reference to a running OLE Application Server.
* Author........: Daniel Rouleau - Metro Information Services
* email: Daniel.Rouleau@MetroIs.com
* Last Revision.: 1998-08-27
*
* Syntax........: GetCurrentOleInstance( tcApplication )
* Returns.......: object or null
* Arguments.....: tcApplication
* Specifies the name of the OLE Application.
*
* Remarks.......: GetNewOleInstance returns a reference to the OLE Application
* Server if it's already running; otherwise it returns Null.
*==============================================================================
FUNCTION GetCurrentOleInstance
LPARAMETERS tcApplication

LOCAL loRetVal && Value returned by this function.
LOCAL lcApplication && Upper case version of tcApplication.
LOCAL loOleApp && OLE automation object.

loRetVal = _SCREEN && To ensure loRetVal is an object.
lcApplication = IIF(TYPE("tcApplication") == "C", UPPER(ALLTRIM(tcApplication)), "")
loOleApp = .F.

* --------------------------
* -- Create an instance of
* -- the appropriate class.
* --------------------------
DO CASE
CASE lcApplication = "WORD"
loOleApp = CREATEOBJECT("clOleWord")
IF (TYPE("loOleApp") == "O") AND NOT ISNULL(loOleApp)
loRetVal = loOleApp.GetCurrentInstance()
ENDIF
ENDCASE

loOleApp = .NULL.
RELEASE loOleApp
CLEAR CLASS loOleApp


RETURN ( loRetVal )

*==============================================================================
* IsOleAppRunning
* ---------------
*
* Purpose.......: Determines if an OLE Application Server is running.
* Author........: Daniel Rouleau - Metro Information Services
* email: Daniel.Rouleau@MetroIs.com
* Last Revision.: 1998-08-27
*
* Syntax........: IsOleAppRunning( tcApplication )
* Returns.......: logical
* Arguments.....: tcApplication
* Specifies the name of the OLE Application.
*
* Remarks.......: IsAppRunnin returns True if the OLE Application is running;
* otherwise it returns False.
*
* IsOleAppRunning instantiates one of the clOleXXX class
* and runs the IsAppRunning method.
*==============================================================================
FUNCTION IsOleAppRunning
LPARAMETERS tcApplication

LOCAL llRetVal && Value returned by this function.
LOCAL lcApplication && Upper case version of tcApplication.
LOCAL loOleApp && OLE automation object.

llRetVal = .F.
lcApplication = IIF(TYPE("tcApplication") == "C", UPPER(ALLTRIM(tcApplication)), "")
loOleApp = .F.

* --------------------------
* -- Create an instance of
* -- the appropriate class.
* --------------------------
DO CASE
CASE lcApplication = "WORD"
loOleApp = CREATEOBJECT("clOleWord")
ENDCASE

* --------------------------------
* -- Run the IsAppRunning method.
* --------------------------------
IF (TYPE("loOleApp") == "O") AND NOT ISNULL(loOleApp)
llRetVal = loOleApp.IsAppRunning()
ENDIF

loOleApp = .NULL.
RELEASE loOleApp
CLEAR CLASS loOleApp


RETURN ( llRetVal )

*==============================================================================
* LaunchOleApp
* ------------
*
* Purpose.......: Launches an OLE Application Server.
* Author........: Daniel Rouleau - Metro Information Services
* email: Daniel.Rouleau@MetroIs.com
* Last Revision.: 1998-09-25
*
* Syntax........: LaunchOleApp( tcApplication )
* Returns.......: logical
* Arguments.....: tcApplication
* Specifies the name of the OLE Application.
*
* Remarks.......: LaunchOleApp returns True if the application is successfully
* launched; otherwise it returns False.
*==============================================================================
FUNCTION LaunchOleApp
LPARAMETERS tcApplication

LOCAL llRetVal && Value returned by this function.
LOCAL lcApplication && Upper case version of tcApplication.
LOCAL loOleApp && OLE automation object.

llRetVal = .F.
lcApplication = IIF(TYPE("tcApplication") == "C", UPPER(ALLTRIM(tcApplication)), "")
loOleApp = .F.

* --------------------------
* -- Create an instance of
* -- the appropriate class.
* --------------------------
DO CASE
CASE lcApplication = "WORD"
loOleApp = CREATEOBJECT("clOleWord")
IF TYPE("loOleApp") == "O" AND NOT ISNULL(loOleApp)
llRetVal = loOleApp.LaunchApp()
ENDIF
ENDCASE

loOleApp = .NULL.
RELEASE loOleApp
CLEAR CLASS loOleApp


RETURN ( llRetVal )
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform