Page 1 of 1 1
Topic Options
#210650 - 2015-09-01 12:04 AM Get Office Details
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Is 7 years too long to get back to this :-)

GetOfficeDetails2() UDF
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=109278


Okay I had a request to get some updated Office information so I looked at this UDF script and aside from Click-To-Run virtual and Microsoft changing back to get the Outlook version from the executable like they do other office applications there really isn't much change. I suppose you could do a check for x86 vs x64 but most people use x86 everywhere I've seen. Checking if (x86) is in the App Path would tell you if it was x86 or x64 so I've not added it. Made a few changes to the code below. If you have time please try it out and let me know. I also did not check on Outlook 2010 if it was using the DLL or the EXE


 Code:
; GetOfficeDetails2.kix
; 8/31/2015 2:46:58 PM Update script to test for newer Office versions
; Check if Office is Click-To-Run install and exit if it is
; (do not have Click-To-Run install so cannot code and test)
; https://msdn.microsoft.com/en-us/library/office/ff864733.aspx
; 7/17/2005 11:17PM
; Updated 7/19/2005 2:25PM
; http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=143052



Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')

Dim $OfficeApps
$OfficeApps = GetOfficeDetails2()
? 'Office Type is : ' + $OfficeApps[10]
? 'Excel Version : ' + $OfficeApps[0]
? 'Word Version : ' + $OfficeApps[1]
? 'PowerPoint Version : ' + $OfficeApps[2]
? 'Access Version : ' + $OfficeApps[3]
? 'Publisher Version : ' + $OfficeApps[4]
? 'Project Version : ' + $OfficeApps[5]
? 'Visio Version : ' + $OfficeApps[6]
? 'Outlook Version : ' + $OfficeApps[7]
? 'FrontPage Version : ' + $OfficeApps[8]
? 'InfoPath Version : ' + $OfficeApps[9]
? 'Virtual Office: ' +  $OfficeApps[11]

Function GetOfficeDetails2(optional $sComputer)
  Dim $A,$B,$P,$Excelver,$Wordver,$PowerPointver,$Accessver,$Publisherver
  Dim $Projectver,$FrontPagever,$Visiover,$Outlookver,$InfoPathver
  Dim $Product,$Office,$VirtualOffice
  Dim $Officeindex,$Officekey,$DetailsArray[12]
  Dim $Index,$RP,$C,$D
  $sComputer=IIf(Not $sComputer,'','\\'+Join(Split($sComputer,'\'),'',3)+'\')
  $A=$sComputer+'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'
  $C=$sComputer+'HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\'
  $D=$sComputer+Left(ReadValue($sComputer+'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir'),1)
  $Index=0
  Select 
    Case KeyExist("HKEY_LOCAL_MACHINE\Software\Microsoft\Office\14.0\Common\InstallRoot\Virtual")
      $VirtualOffice=1
      Exit
    Case KeyExist("HKEY_LOCAL_MACHINE\Software\Microsoft\Office\15.0\Common\InstallRoot\Virtual")
      $VirtualOffice=1
      Exit
    Case 1
      $VirtualOffice=0
  EndSelect
  $B=EnumKey($A+'\',$Index)
  If @ERROR Exit @ERROR EndIf
  While @ERROR=0
    If $sComputer 
      $RP=$D+'$'+Right(ReadValue($A+'\'+$B,'path'),-2)
    Else
      $RP=ReadValue($A+'\'+$B,'path')
    EndIf
    Select
      Case $B='excel.exe'
        $Excelver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='winword.exe'
        $Wordver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='powerpnt.exe'
        $PowerPointver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='msaccess.exe'
        $Accessver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='mspub.exe'
        $Publisherver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='winproj.exe'
        $Projectver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='visio32.exe'
        $Visiover=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='outlook.exe'
        Select
          Case KeyExist("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0")
            $Outlookver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
          Case 1
            $Outlookver=GetFileVersion($RP+'\'+'OUTLLIB.DLL','BinFileVersion')
        EndSelect 
      Case $B='frontpg.exe'
        $FrontPagever=GetFileVersion($RP+'\'+$B,'BinFileVersion')
      Case $B='infopath.exe'
        $InfoPathver=GetFileVersion($RP+'\'+$B,'BinFileVersion')
    EndSelect
    $Index=$Index+1
    $B=EnumKey($A+'\',$Index)
  Loop
  $Officeindex=0
  $Officekey=EnumKey($C,$Officeindex)
  If @ERROR Exit @ERROR EndIf
  While @ERROR=0 And $Office=0
    $Product=ReadValue($C+$Officekey,'DisplayName')
    If InStr ($Product, 'Microsoft Office') And Not InStr($Product,'Live Meeting') And Not InStr($Product,'Studio')
      $Office=$Product
    EndIf
    $Officeindex=$Officeindex+1
    $Officekey=EnumKey($C,$Officeindex)
  Loop
$DetailsArray[0]=$Excelver    $DetailsArray[1]=$Wordver        $DetailsArray[2]=$PowerPointver
$DetailsArray[3]=$Accessver   $DetailsArray[4]=$Publisherver   $DetailsArray[5]=$Projectver
$DetailsArray[6]=$Visiover    $DetailsArray[7]=$Outlookver     $DetailsArray[8]=$FrontPagever
$DetailsArray[9]=$InfoPathver $DetailsArray[10]=$Office        $DetailsArray[11]=$VirtualOffice
$GetOfficeDetails2=$DetailsArray
EndFunction

Top
#210651 - 2015-09-01 03:20 AM Re: Get Office Details [Re: NTDOC]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
This is blatant stealing of Lonk's code but it might be a good start...

 Code:
? OfficePath



function OfficePath(optional $computer)
  dim $regview, $rootkey,$c,$s,$k,$bs[1],$b,$e
  dim $officeVersion
  $regview = setoption("wow64alternateregview","on")
  $rootkey = iif($computer,"\\"+$computer+"\","")+"hklm\software"
  $e="0011","011D","0012","0013","0014","002F","008B","002E","0030","0031","0033","0035","00CA"
  $bs="","\wow6432node"
  $c=0
  for each $b in $bs
    do
      $k = enumkey($rootkey + $b + "\microsoft\windows\currentversion\uninstall",$c)
      if right($k,17)="000-0000000FF1CE}"
        $s=split($k,"-")[1]
        if -1<ascan($e,$s)
          $OfficeVersion=split(readvalue($rootkey+$b+"\microsoft\windows\currentversion\uninstall\"+$k,"DisplayVersion"),".")[0]
          $OfficePath=readvalue($rootkey+$b+"\microsoft\windows\currentversion\uninstall\"+$k,"InstallLocation") + "Office" + $OfficeVersion
        endif
      endif
      $c=$c+1
    until $k="" or $officePath<>""
  next
  $regview=setoption("wow64alternateregview",$regview)
endfunction

Top
#210652 - 2015-09-01 08:52 AM Re: Get Office Details [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Current system does not have Office on it so can't test but will test at work. My code does work it just is not trimmed down for GOLF

But if his is better that's cool too :-)

Top
#210653 - 2015-09-01 09:00 AM Re: Get Office Details [Re: NTDOC]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Got curious and ran it on another computer and it comes back blank for me.
Will have to go find the UDF and see if there is a minimum KiX version listed.

Top
#210655 - 2015-09-01 09:14 AM Re: Get Office Details [Re: NTDOC]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Well a board search and a Google search does not bring up that UDF code Allen. Did Lonkero post it in private or some other location?
Top
#210658 - 2015-09-01 02:16 PM Re: Get Office Details [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Hmm.
http://www.kixtart.org/udf/

Does list office bitness and version udfs.

I have not tested those with 2015 though.
_________________________
!

download KiXnet

Top
#210663 - 2015-09-01 03:47 PM Re: Get Office Details [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Based on

OfficeVersion -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=208400

;Dependencies
; 4.63+ version of kixtart

Top
#210665 - 2015-09-01 07:24 PM Re: Get Office Details [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Odd. Wonder why Google did not find that
Let me play around with it more. I was using 4.53 on that other system.

Top
#210666 - 2015-09-01 07:27 PM Re: Get Office Details [Re: NTDOC]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
I see why. You modified the function name I was looking for.
Top
#210668 - 2015-09-01 07:52 PM Re: Get Office Details [Re: NTDOC]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
So on my desktop both functions work with 4.66

In theory one could have different versions of Office Applications but now days it's probably not as common so using Lonkero's code should be good enough for "most" purposes.

Now need to see what to use for remote OS check. OSID UDF at 11 years old not cutting the mustard anymore. Maybe I'll look around Glenn's site as I'm sure he's using something for remote OS checks.

Top
#210686 - 2015-09-03 10:37 AM Re: Get Office Details [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
The difference is, my udf looks for an office install and completely ignores word, excel and other software because they are not office. They are part of it or separate. So even if you have office 2010 pro plus on your computer and have chosen to leave the office 2003 applications on your computer during install, you still have only one version of office installed.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 739 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.077 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org