Search code examples
excelvbaexcel-formulalibreoffice-calc

Detect software used to open an XLSX file with Macro or VBA


I search a way to know if an XLSX file is currently opened in Excel, libreoffice-calc or another sheet software.

The goal is to display a warning in a cell only if the file is NOT open with excel.

Is there an official Macro that would allow that? Or maybe a trick with a macro existing in excel and not libreoffice?

Or as a last resort, a solution to detect this information in VBA script?

Thanks!



Solution

  • In case of Excel the following

    Application.Name
    

    will return Microsoft Excel, and

    Application.Version
    

    will return the Excel version like 16.0.

    You can write a warning into a cell like "Please open edit this file only with Excel" and remove it with an Excel VBA code. Note that the warning will then be also there if Macros are disabled.