view · edit · history · print

howto find excel?!

Using Registry

  
HKEY_CLASSES_ROOT\Excel.Application\CurVer
Excel.Application.14
=> works in XP_x32 & win7_x64

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\EXCEL.EXE\shell\Open\command
=> does not exist in win7 (not usable or common)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Common
=> does not contain the default version on win7 (not usable or common)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe
C:\PROGRA~1\MICROS~2\Office14\EXCEL.EXE
=> seems to be most reliable

Query from Command line

  
> reg QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe" /ve

WinXP output (32bit)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe
    <NO NAME>   REG_SZ  C:\PROGRA~1\MICROS~2\Office14\EXCEL.EXE

Win7 output (64bit)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe
    (Default)   REG_SZ  C:\PROGRA~1\MICROS~2\Office14\EXCEL.EXE

Batch file (first attempt)

  
@ECHO OFF
:: delims is a TAB followed by a space
FOR /F "tokens=2* delims=	 " %%A IN ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe" /ve') DO SET Value=%%B
ECHO VAL1=%Value%

=> depending on windows version the default value is returned as <NO NAME> or (Default) => this means tokens=2* or tokens=3* needs to be set - grrrr, hate this!

Batch file (second option)

  
@ECHO OFF
:: delims is a TAB followed by a space
FOR /F "tokens=2* delims=	 " %%A IN ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe" /v Path') DO SET Value=%%B
set FULLPATHEXCEL=%Value%EXCEL.EXE
:: example C:\Program Files\Microsoft Office\Office14\EXCEL.EXE
echo launching %FULLPATHEXCEL% ...
start "Excel" "%FULLPATHEXCEL%" /e %1

=> save that batch file, Right click an excel file and select "Open With…" <batchfile>

Reference: http://brett.batie.com/software-development/open-excel-in-two-windows-excel-2007-vista/

admin · attr · attach · edit · history · print
Page last modified on December 28, 2011, at 02:26 AM