Detect if VBA is running under LibreOffice or Excel

I have some Excel spreadsheets with VBA macros that almost run under both Excel and LibreOffice Calc. I can tweak the code to work with either. Is there an easy way for the macro to detect at runtime which software it is running on, so I can execute different code accordingly? I’ve been mandated to migrate our whole business to LO, and during the transition we need to be able to use certain files with both programs.

Thanks JohnSUN. That approach doesn’t work, unfortunately. Excel reports a “compile error” on the line that starts with “if (Not GlobalScope…” Since it is a compilation error, the on error statement doesn’t trap it. This may make what I am trying to do hopeless: In most cases, the code written for LO is going to prevent the whole macro from compiling.

Thanks JohnSUN. That approach doesn’t work, unfortunately. Excel reports a “compile error” on the line that starts with “if (Not GlobalScope…” Since it is a compilation error, the on error statement doesn’t trap it.

May be so?

Public isOpenOffice As Boolean

Private Sub Workbook_Open()
isOpenOffice = isLiO
If isOpenOffice Then
    MsgBox "Calc run.", vbOKOnly + vbInformation, "Info"
Else
    MsgBox "Excel run.", vbOKOnly + vbInformation, "Info"
End If
End Sub

Function isLiO() As Boolean
Dim oDoc
    isLiO = False
    On Error GoTo NotLiO
    If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then GlobalScope.BasicLibraries.LoadLibrary ("Tools")
    isLiO = True
NotLiO:
    
End Function