This question is for calling Python from Excel. In VBA you'd do your RunPython("import mymodule; mymodule.my_function()")
In Python you would have something like,
from xlwings import Workbook, Sheet, Range
def my_function():
wb = Workbook.caller() # Create reference to calling Excel file
Range('A1:C3').clear_contents() # Clear some cells
My question is that this will work for your first instance of Excel. But in the event you have two instances open, and you're trying to run the code in the second instance, you will get a raised exception saying, "Can't establish connection! Make sure the calling workbook is the active one and is opened in the first instance of Excel."
So it seems like this is designed to work on only the first instance. Is there a way around this? Can you identify which instance you're in in the Python script? The user was hoping to run VBA macros that call Excel across multiple instances.