I would like to summarize the template creation of a script that executes Python code by placing an execute button in Excel and pressing it. Here we use xlwings quickstart.
OS: macOS Catalina 10.15.3 python: Python 3.7.9
$ xlwings addin install
If successful, the following will be displayed.
xlwings version: 0.20.7
Successfully installed the xlwings add-in! Please restart Excel.
Successfully enabled RunPython!
Select Tools> Excel Add-ins to adapt the add-in Press "Browse" in the pop-up that appears, search for *** xlwings.xlam *** and select-> Press Open File. OK if Xlwings is selected as a valid add-in.
Close all Excel and open the target Excel again. It is OK if xlwings is added to the Excel menu.
Change to the directory where you want to create the project
Execute the following on the command line. For the project name, specify the name of the project you want to create.
$ xlwings quickstart {{Project name}}
Open VBE (Visual Basic Editor). Shortcut key is "Alt + F11" Confirm that the following screen opens.
Go back to Excel and create a run button. (Here, insert an appropriate figure and insert something like a button.)
Right-click on the shape and select "Register Macro".
Select *** SampleCall *** here, check that it is reflected in the macro name field, and press OK. As a result, when you press the shape, SampleCall will be executed.
You have now created a template to execute Python code from Excel! !!
Recommended Posts