0

Is there a way to determine which Excel version I’m using via code, basically I need to figure out whether I’m on Office 365 or an older version.

import win32com.client
import xlwings as xw 

xl = win32com.client.gencache.EnsureDispatch(“Excel.Application”)
wb = xl.Workbooks.Add()
wb_xw = xw.books[wb.name]
buran
  • 13,682
  • 10
  • 36
  • 61
Peter
  • 27
  • 3

1 Answers1

0

I think Below Code can Help you :

from win32com.client import Dispatch
def get_version_via_com(filename):
    parser = Dispatch("Scripting.FileSystemObject")
    version = parser.GetFileVersion(filename)
    return version
if __name__ == "__main__":
    path = r"Excel_path"
    print(get_version_via_com(path))
  • brackets in `(__name__ == "__main__")` are redundant. – buran Oct 30 '21 at 08:02
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Tyler2P Oct 30 '21 at 08:40