Reputation: 73
I started a project in xlwings called MakeReport. So I have two files: 1) MakeReport.xlsm and 2) MakeReport.py. My python functions in MakeReport.py write data to a third excel sheet called Template.xlsm. They were all in the same directory. I then wrote macros in Makereport.xlsm that triggered specific MakeReport.py functions. Then in Template.xlsm I made buttons and assigned them to the respective macros from MakeReport.xlsm. Everything at this point is working fine.
I wanted the Template.xlsm file to be in a new directory so I took it out of the folder with my MakeReport files. The macros are still linked. When I run my macros directly in MakeReport.xlsm, everything works fine and the correct data populates to Template.xlsm. However, when I try and use the buttons in Template.xlsm, I get the following error: No module named 'MakeReport'
Why is this happening?
Here is my VBA code:
Sub TestRun()
RunPython("import MakeReport;MakeReport.test_run()")
End Sub
Upvotes: 0
Views: 377
Reputation: 73
Figured it out. Just need to create a xlwings.config sheet in the Template.xlsm workbook and then specify the PYTHONPATH.
Upvotes: 1