def _get_latest_app():
    """
    Only dispatch Excel if there isn't an existing application - this allows us to run open_workbook() and
    new_workbook() in the correct Excel instance, i.e. in the one that was instantiated last. Otherwise it would pick
    the application that appears first in the Running Object Table (ROT).
    """
    try:
        return xl_workbook_current.Application
    except (NameError, __HOLE__, pywintypes.com_error):
        return dynamic.Dispatch('Excel.Application')
dataset/ETHPy150Open ZoomerAnalytics/xlwings/xlwings/_xlwindows.py/_get_latest_app