Excel version identification programmatically

My VB.NET (3.5) application creates Excel reports.

Newer versions of Excel support the Office Open XML format , while older versions do not.

I want my application to identify which version of Excel is installed on the local computer and use a different method to generate the report (New versions: by generating an XML file. Old versions: using Excel Automation).

How to determine the version of Excel installed on the local computer?

+4
source share
2 answers

You can see one of the following registry keys:

HKEY_USERS\.DEFAULT\Software\Microsoft\Office\11.0\Excel HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel 

You should look for the key with "Excel" in it, since you can have Office 2003 installed, and visio 2007 aside, so both keys will exist, but only one will have an Excel subkey:

 HKEY_CURRENT_USER\Software\Microsoft\Office\11.0 HKEY_CURRENT_USER\Software\Microsoft\Office\12.0 

Matching numbers / versions

  • Office 9: Office 2000
  • Office 10: Office XP (first version to support XML worksheets)
  • Office 11: Office 2003
  • Office 12: Office 2007
  • Office 14: Office 2010 (fun fact, 13 was skipped)
+3
source

You can open an instance of Excel and check the version:

 Dim appExcel As Object appExcel = CreateObject("Excel.Application") With appExcel Debug.Print(Val(.application.version)) .quit() appExcel = Nothing End With 
+4
source

Source: https://habr.com/ru/post/1347441/


All Articles