I have installed all xlwings packages and created a new project using the
xlwings quickstart demo4
line in my terminal (note that I have a Mac). I tried to run the demo4.py file that gets created in the demo4 folder by clicking on the Run main button, but I get the following error message:
"Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'demo4'"
The output should be "Hello world" in cell A1, but it does not seem to be working. The python code looks like this:
import xlwings as xw
def main():
wb = xw.Book.caller()
sheet = wb.sheets[0]
if sheet["A1"].value == "Hello xlwings!":
sheet["A1"].value = "Bye xlwings!"
else:
sheet["A1"].value = "Hello xlwings!"
if __name__ == "__main__":
xw.Book("demo4.xlsm").set_mock_caller()
main()
The VBA code like this:
Sub SampleCall()
mymodule = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".", -1, vbTextCompare) - 1))
RunPython "import " & mymodule & ";" & mymodule & ".main()"
End Sub