3

I am using python 3.9.7. I would like to ask if there is a way python can determine if Excel is installed and also return the version number of Excel if Excel is installed.

Kent Choo
  • 35
  • 5
  • [Get a List of Installed Softwares in Windows using Python](https://www.geeksforgeeks.org/get-a-list-of-installed-softwares-in-windows-using-python/) – Nin17 Jul 24 '22 at 08:34

1 Answers1

3

You can use ProgID to determine this:

import win32com.client

try:
    excel = win32com.client.Dispatch("Excel.Application")
    version = excel.version
    print("Excel version:", version)
except:
    print("There are no excel installed")

There is Office 365 installed on my PC, and I get this output:

Excel version: 16.0

I also recommend you to read this article.

  • 2
    The [article](https://pbpython.com/windows-com.html) you provided says you need windows installed for pywin32 to work. What happens if someone uses Mac or Linux Os? I am using windows myself but am writing a program for others. – Kent Choo Jul 24 '22 at 09:52
  • @KentChoo, yes it looks like a problem for multiplatform applications. In the case of Linux OS, it's easy, there is no Excel at all:) I'm unable to answer about Mac because I do not use it. However, I hope this will be helpful: https://stackoverflow.com/questions/15164132/enumerate-all-installed-applications-on-os-x – Tim Shidlovskii Jul 24 '22 at 10:07
  • thanks for the explanation @Tim Shidlovskii – Kent Choo Jul 24 '22 at 13:07