Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The following code snippet gets a list of all the installed copies of Excel on the computer (this has been tried and tested on a Windows XP machine, running both Excel 2003 and 2007).</p> <pre><code>Dim reg As RegistryKey Dim subKey As RegistryKey Dim rtn As New Dictionary(Of String, String) reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Office") If reg IsNot Nothing Then For Each subKeyName As String In reg.GetSubKeyNames subKey = reg.OpenSubKey(subKeyName) If subKey IsNot Nothing Then If subKey.GetSubKeyNames().Contains("Excel") Then subKey = subKey.OpenSubKey("Excel\InstallRoot") rtn.Add(subKeyName, subKey.GetValue("Path").ToString) End If End If Next End If For Each kvp In rtn MessageBox.Show(String.Format("Version: {0} at '{1}Excel.exe'", kvp.Key, kvp.Value)) Next </code></pre> <p>In the variable <code>rtn</code> you have a dictionary of the versions (the key) and the directory that Excel is installed in (the value). As you can see in the <code>MessageBox</code> bit at the end of my code, you'll need to add "Excel.exe" to the end of it.</p> <p>Now you have the location of the installed copies of Excel and their versions, you can create a form which lists them, to allow for the user to select which version they wish to use.</p> <p>Whilst I'm sure you can find the command line for opening an Excel spreadsheet with Excel, I thought I would include it here for completeness;</p> <pre><code>excel.exe "c:\My Folder\book1.xlsx" </code></pre> <p>(<a href="http://office.microsoft.com/en-us/excel-help/command-line-switches-for-excel-HA010158030.aspx" rel="nofollow">http://office.microsoft.com/en-us/excel-help/command-line-switches-for-excel-HA010158030.aspx</a>)</p> <p>A slightly more full explanation of <a href="http://satalketo.com/2011/08/installed-excel-versions/" rel="nofollow">how to identify installed Excel versions and their location</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload