Office version

Office version

Postby MdaSolution » Tue Nov 30, 2010 12:01 pm

How I can detect wich version of Office is on my computer ?
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: Office version

Postby ukoenig » Tue Nov 30, 2010 2:30 pm

You have to Install < Windows-Power-Shell 2.0 > or use it, if already installed, to get the Informations You need .

http://support.microsoft.com/kb/968929

http://blogs.technet.com/b/heyscripting ... rsion.aspx

From the Link above :

using Windows PowerShell. You can detect the “version of Office” by querying the product version of Word / Excel / PowerPoint / Outlook, and so on. There is no gobal GUID to represent the version of office that is installed. In addition, it may be that one has Office 2010 installed, has Word 2003 installed as well, and maybe even Outlook 2007. So a mix and match situation could very well exist that would make extrapolating what version of Office is actually installed on the machine problematic.

In addition, problems can occur as to what version of Office is installed because of Professional version, Ultimate edition, Student edition or one of the other editions of Office that consist of different suites of applications.

Ultimately, one must describe what is meant by “what version of Office” is installed. One way to do this is to determine why the information is to be collected. For example, are you trying a software inventory, trying to detect update status, seeking information to determine upgrade costs, searching for machines that were possibly missed during an upgrade cycle, or for computers that do not have enough horsepower to stand an upgrade to the most recent edition of Office.

Using the WMI class, Win32_Product can be a bit slow. However, the ability to run it as a background job in Windows PowerShell reduces this really well. It is a fire and forget operation. You can query the registry for Office keys. However, you have to allow for all different variations of the configuration. You can also query file versions but that will require you to check for every possible combination of service pack and hotfix as the file versions change at service pack levels.

From a most basic stance, you can decide that if a computer has Microsoft Excel version 12 installed, it is running Office 12. Frequently such a broad stroke is sufficient.

Microsoft Configuration Manager creates custom WMI classes that can be used to query for Office version information. The WMI classes work very well, and retrieve their information from the registry. You can take that approach if you do not have Configuration Manager installed. In addition, there is an Office inventory tool that can be downloaded. It works well, but I am not certain if it was updated to detect Office 2010. The tool seems old, having been written back in 2006, but perhaps it will work for you. If you decide to go the registry route, or the file version route, there is an excellent KB article that gives you the information that you will need.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Office version

Postby Otto » Tue Nov 30, 2010 2:40 pm

Best regards,
Otto

Code: Select all  Expand view
 

TRY
   oWord := CREATEOBJECT( "Word.Application" )
   if VAL(oword:Version) < 12
      msginfo("Sie haben nicht die notwendige WINWORD-Version installiert!")
   else
      MsgInfo( oword:path  )
   endif
endif

oWord:Quit()

CATCH
msginfo( "Fehler mit :  CREATEOBJECT Word.Application" )
END


 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6025
Joined: Fri Oct 07, 2005 7:07 pm

Re: Office version

Postby ukoenig » Tue Nov 30, 2010 3:59 pm

A Version-detector ( C-Function ) :

Image

Detector ( 84 KB )

http://www.pflegeplus.com/fw_downloads/officevers.zip

I couldn't test with Office 2010, if it is included with the Version-strings :

Code: Select all  Expand view

static eOfficeVersion StringToVersion(const CString& versionString)
{
// mapping between the marketing version (e.g. 2003) and the behind-the-scenes version
if(_T("7") == versionString){
   return eOfficeVersion_95;
}else if(_T("8") == versionString){
   return eOfficeVersion_97;
}else if(_T("9") == versionString){
  return eOfficeVersion_2000;
}else if(_T("10") == versionString){
  return eOfficeVersion_XP;
}else if(_T("11") == versionString){
  return eOfficeVersion_2003;
}else if(_T("12") == versionString){
  return eOfficeVersion_2007;
}else{
  return eOfficeVersion_Unknown; // added another ???
}
}
 


Also You can use a VBS-Script with the same Result.
Save this as < CheckOffice.vbs >
A dbl-click on this file shows the versions.
Also You can call it from inside Your application. Winexec('WSCRIPT.exe CheckOffice.VBS')

the post includes some more Informations of other users :
viewtopic.php?f=3&t=15773&p=81673&hilit=vbs#p81673

Image

You can add more (newer) Versions :

Call ChkOffice("12.0","2007")
Call ChkOffice("????","2010")

Code: Select all  Expand view

Dim WSHShell, objFSO, textout
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("WScript.Shell")

Dim part(4,1)
 part(0,0) = "Word"       : part(1,1) = "WINWORD.EXE"
 part(1,0) = "Excel"      : part(2,1) = "EXCEL.EXE"
 part(2,0) = "Outlook"    : part(4,1) = "OUTLOOK.EXE"
 part(3,0) = "PowerPoint" : part(0,1) = "POWERPNT.EXE"
 part(4,0) = "Access"     : part(3,1) = "MSACCESS.EXE"

textout = "Installed Office-Applications :" & vbCRLF & vbCRLF

Call ChkOffice("12.0","2007")
Call ChkOffice("11.0","2003")
Call ChkOffice("10.0","XP")
Call ChkOffice("9.0", "2000")
Call ChkOffice("8.0", "97")

MsgBox textout,64,"CheckOffice.vbs"

Function ChkOffice(ver, verfull)
 Dim pfad, res, helptext

 On Error Resume Next
 pfad = "HKLM\Software\Microsoft\Office\" & ver & "\Common\InstallRoot\Path"
 res = WSHShell.RegRead(pfad)
 If res <> "
" Then
  For i = 0 to 4
   If objFSO.FileExists(res&part(i,1)) Then
    helptext = part(i,0) & Space(1) & verfull & "
 (" & objFSO.GetFileVersion(res&part(i,1))&")"
    textout = textout & helptext & vbCRLF
   End If
  Next
  textout = textout & vbCRLF
 End If

End Function


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Office version

Postby MdaSolution » Wed Dec 01, 2010 11:08 am

Dear Otto,
I need to Know the string of registry because I must set a customer space to save documents for all Office applications

sample :

I want set FOLDER c:\docu

and the final usrs can save only on this folder :

HKEY_CURRENT_USER\Software\Microsoft\Office\[Version]\Common\Open Find\Places\UserDefinedPlaces

Name: Name, Path

Type: REG_SZ (String Value)


THE PROBLEM IS WICH [Version]


SAMPLE :
Open your registry and find the key below.
For Office 2000 replace [version] with "9.0" in the registry key, or "10.0" for Office XP which is internally known as Office 10

BUT i WISH FOUND IT FROM SOURCE CODE

ANY i DEA ?
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: Office version

Postby Otto » Wed Dec 01, 2010 1:33 pm

Maybe there are methods or DATA like

oword:UserDefinedPlaces
Please try with VBA to find out the syntax.

path is working for me.

MsgInfo( oword:path )

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6025
Joined: Fri Oct 07, 2005 7:07 pm

Re: Office version

Postby StefanHaupt » Thu Dec 02, 2010 12:38 pm

with this function you can read all installed programs.
You can easily make some changes, to get only MS office products.

Code: Select all  Expand view
FUNCTION GetAllApps ()

 LOCAL oWmi, objWMI, oApp
 LOCAL strComputer := ".", aApps := {}

  local objWMIService, colitems,objitem

  oWMI := CheckWMI ()
  IF oWMI != nil

    objWMI:= oWMI:ConnectServer()
    CursorWait ()
    oApp:= objWMI:ExecQuery("SELECT * FROM Win32_Product")

    For Each objItem in oApp
      AAdd (aApps, {cValToChar(objItem:Description), cValToChar(objItem:Version)})
    Next
    CursorArrow()
    Asort(aApps,,, {|x,y| x[1] < y[1] })
  ELSE
    ? "WMI not installed"
  ENDIF

RETURN (aApps)
//-------------------------------------------
FUNCTION CheckWMI ()

  LOCAL oWMI, oErr

  TRY
    oLoc := CreateObject( "wbemScripting.SwbemLocator" )
  CATCH oErr
    oWMI := nil
  END

RETURN (oWMI)
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Office version

Postby MdaSolution » Thu Dec 02, 2010 7:57 pm

wmi not installed !!!


Any help for instal it ?
I tried on Windows Seven Ultimate
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: Office version

Postby StefanHaupt » Fri Dec 03, 2010 8:50 am

Hmm, it should be installed by default. But here are some links to solve the problem

Wmi Trobleshooting http://technet.microsoft.com/de-de/library/ee692772%28en-us%29.aspx

Rebuild WMI in Server 2003 http://musumeci.blogspot.com/2009/01/ms-rebuild-wmi.html

Rebuild WMI Win 7 http://www.sevenforums.com/tutorials/57746-system-restore-general-troubleshooting-fix-issues.html
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 9 guests