Sign in to follow this  
Followers 0
Carlos

Excel Path

4 posts in this topic

I want to read out the path where excel is installed.

Is this possible?

Share this post


Link to post
Share on other sites



With Office 2003, the default value of the key "HKEY_CLASSES_ROOT\Applications\EXCEL.EXE\shell\edit\command" has the full path to Excel. The entry is actually "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e, so you'd need to strip out the quotes and the trailing /e like this:

$ExcelPath = RegRead ( 'HKEY_CLASSES_ROOT\Applications\EXCEL.EXE\shell\edit\command', '' )
If StringLeft ( $ExcelPath, 1 ) = '"' Then
    $ExcelPath = StringTrimLeft($ExcelPath,1)
EndIf
$ExcelPath = StringTrimRight( $ExcelPath, StringLen($ExcelPath)-StringInStr($ExcelPath,'"',1)+1 )
MsgBox ( 0, @ScriptName, $ExcelPath )

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

JerryD - Good solution for certain versions of Office

Unfortunately mine doesn't have command line parameters.

This is more fool proof.

;Returns path with trailing backslash
$excelFolder = RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe", "Path" )
If StringRight($excelFolder, 1) <> "\" Then $excelFolder &= "\"
$excelPath = $excelFolder & "excel.exe"
Edited by weaponx

Share this post


Link to post
Share on other sites

You're absolutely right! App Paths is EXACTLY where to check. I stand corrected.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0