FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Check if Word or Excel is installed
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM

Check if Word or Excel is installed

Posted: Fri Jan 09, 2015 01:15 PM

Hi,

Probably is the aswer already in the forum, but I don't find it.
Is there a way to check if Word if Excel is installed on the PC?

Thanks,

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Check if Word or Excel is installed

Posted: Fri Jan 09, 2015 01:25 PM
Marc,

Code (fw): Select all Collapse
TRY
    oWord = CREATEOBJECT( "Word.Application" )
CATCH
    ? "Not installed"
END


EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Check if Word or Excel is installed

Posted: Fri Jan 09, 2015 01:59 PM

Because FWH has special function to create excel and word objects you can also use:

if ExcelObj() == nil // not installed
if WinWordObj() == nil // word not installed

Regards



G. N. Rao.

Hyderabad, India
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM

Re: Check if Word or Excel is installed

Posted: Fri Jan 09, 2015 02:59 PM
This is a little routine to get the version # of that latest version of office still installed.
nVer := MSOfficeVer()
if nVer = 0
// Not installed
elseif nVer := 14
// Office 2010
endif

Code (fw): Select all Collapse
function MSOfficeVer()
   local oReg, nVer := 0
   local nCounter, cPath, cKey
   /*
   oReg  := TReg32():New( HKEY_LOCAL_MACHINE, ;
              "SOFTWARE\Microsoft\Office\Common" )
   nVer  := oReg:Get( 'LastAccessInstall', nVer )
   oReg:Close()
   */
   for nCounter := 20 to 10 step -1
      cKey := "SOFTWARE\Microsoft\Office\"+ltrim(str(nCounter,4,1))+"\Common\InstallRoot"
      oReg  := TReg32():New( HKEY_LOCAL_MACHINE, cKey )
      cPath  := oReg:Get( 'Path', cPath )
      oReg:Close()
      if cPath != nil .and. file( cPath+"excel.exe" )
         nVer := nCounter
         exit
      endif
   next
return nVer
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM

Re: Check if Word or Excel is installed

Posted: Sat Jan 10, 2015 09:15 AM

Enrico, Rao, Gale,

Thanks for the reply, I will test it.

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite

Continue the discussion