Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Matin Aziz
  Where is Matin Aziz?
 New York
 New York - United States
 Matin Aziz
 To: Tamar Granor
  Where is Tamar Granor?
 Elkins Park
 Pennsylvania - United States
 Tamar Granor
 Tags
Subject: RE: Version of Microsoft Office installed
Thread ID: 345351 Message ID: 345366 # Views: 39 # Ratings: 0
Version: Visual FoxPro 8 Category: Microsoft Office Automation
Date: Tuesday, May 22, 2012 10:52:11 PM         
   


> > Hi Everyone,
> > I would like to know if there is a way to detect what Version of Microsoft Office is installed on a computer.
> > I have the following code samples :
> >
> > o = createobject('Outlook.application')
> > ? o.version
> >
> > e = createobject('Excel.application')
> > ? e.version
> >
> > w = createobject('Word.application')
> > ? w.version
> >
> > The only problem is that this code would open those applications and keeps it open in the background.
> > Is there any way to get the version without opening the applications.
>
> The alternative is to find the EXE and check its version. To find the EXE, you have to look for the appropriate server in the Registry. Here's code that looks up the registered server and returns the associated file name. It's based on code in the book Della Martin and I wrote about automating Office:
>
>
> * CheckServer.prg
> * © 2000, Tamar E. Granor and Della Martin
> * From:  Microsoft Office Automation with Visual FoxPro
> * Hentzenwerke Publishing. www.hentzenwerke.com
> 
> LPARAMETER cServerName
> 
> LOCAL oRegistry, cClassID, cEXEName, lEXEExists, ;
>       aClassIDValues, aClassIDValues, aServerNameValues
> 
>   oRegistry = NewObject("Registry", HOME() + "FFC\Registry")
> 
> lEXEExists = .F.
> DECLARE aClassIDValues[1], aServerNameValues[1]
> 
> WITH oRegistry
> 
>   * Find the CLSID of the server. First, look for
>   * the Class's Key.
>   IF .OpenKey(cServerName + "\CLSID") = 0
> 
>     * The Class's Key is open, now enumerate its values
>     .EnumKeyValues(@aClassIDValues)
>     
>     * The data portion of the first (only) value returned
>     * is the CLSID. Find the LocalServer32 key for the CLSID
>     IF .OpenKey("CLSID\" + aClassIDValues[1,2] + "\LocalServer32") = 0
> 
>       * Enumerate teh LocalServer32 values
>       .EnumKeyValues(@aServerNameValues)
>       
>       * The EXE file is stored in the first (only) data value returned. 
>       cEXEName = aServerNameValues[2]
>       
>       * The value that's returned may have " -Automation" or " /Automation" or
>       * " /AUTOMATION" & other trailing stuff at the end. Strip it off.
>       IF "AUTO" $ UPPER(cEXEName)
>         cEXEName = LEFT(cEXEName, ATC("AUTO", UPPER(cEXEName)) - 2)
>       ENDIF
>       
>     ENDIF     
>   ENDIF
> ENDWITH
> 
> RETURN m.cEXEName
> 

>
> Once you have the EXE name, just use AGetFileVersion() to look up the version number:
>
>
> AGetFileVersion(aVersionInfo, m.cEXEName)
> 

>
> Tamar

Thanks Tamar for the response.
I am not sure what value goes for cServerName to get the EXE for outlook or word.

Thanks

Matin

ENTIRE THREAD

Version of Microsoft Office installed Posted by Matin Aziz @ 5/22/2012 8:28:03 PM
RE: Version of Microsoft Office installed Posted by Borislav Borissov @ 5/22/2012 8:39:14 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/22/2012 8:45:00 PM
RE: Version of Microsoft Office installed Posted by Borislav Borissov @ 5/22/2012 8:50:13 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/22/2012 8:57:56 PM
RE: Version of Microsoft Office installed Posted by Borislav Borissov @ 5/22/2012 9:01:10 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/22/2012 9:19:14 PM
RE: Version of Microsoft Office installed Posted by Borislav Borissov @ 5/22/2012 9:34:20 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/22/2012 10:23:22 PM
RE: Version of Microsoft Office installed Posted by Tamar Granor @ 5/22/2012 10:29:34 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/22/2012 10:52:11 PM
RE: Version of Microsoft Office installed Posted by Borislav Borissov @ 5/22/2012 10:59:33 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/22/2012 11:10:52 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/23/2012 8:57:06 PM
RE: Version of Microsoft Office installed Posted by Tamar Granor @ 5/23/2012 11:04:34 PM
RE: Version of Microsoft Office installed Posted by Matin Aziz @ 5/23/2012 11:19:29 PM
RE: Version of Microsoft Office installed Posted by Tamar Granor @ 5/24/2012 10:27:38 PM