Jump to content

Excel Path


Carlos
 Share

Recommended Posts

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 )
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...