Setting up your editor to allow Python code debugging for functions called from Excel can be tricky, depending on the details of your editor and linking software, but using the Visual Studio Code Editor and Pyxll, this works for me:
- Open the Python code in the Visual Studio Code editor.
- Make sure the Python code Extension is installed (check under File-Preferences-Extensions).
- Open the folder containing the code file. Either use File-Open Folder …, or click on the Explorer icon (top icon on the left hand icon bar).
- Go to the Excel File that will be calling the Python functions, and link to the editor from the Add-ins – Pyxll – Attach to VS Code menu:
- Return to Visual Studio Code and click the Run icon in the left hand tool bar …
- … then click the green arrow between Run and Python Attach. The blue bar at the bottom of the screen should turn orange:
- Finally click in the left hand margin on a line where you like to insert a break point …
- … and return to Excel and call the routine to be de-bugged.
The code will stop at the selected break point. You can then step through the code using the Run menu, use the function key short-cuts, or right click for debug options.
See https://www.pyxll.com/blog/debugging-your-python-excel-add-in/ for full instructions, including how to add the “Attach to VS Code” menu item in Excel (it is not included by default).
Are you changing your main language to Python or will be improvements vba codes??
I am working on moving the most generally useful applications to Python, but there will still be VBA related posts (there were two last month for instance).
maybe we can integrated with freeCAD your codes and build an complete software for the community?
I will spend my time to follow your blog with new codes in python so now. I just has a few UDFs in VBA can help me, like import dxf points and frames….