Kent Choo
Kent Choo

Reputation: 35

Use python to detect Excel installation

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.

Upvotes: 3

Views: 530

Answers (1)

Tim Shidlovskii
Tim Shidlovskii

Reputation: 124

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.

Upvotes: 3

Related Questions