Developer Tools

Reloading

When PyXLL is configured in developer mode it is possible to reload the modules imported by PyXLL using the Reload menu item in the PyXLL Excel addin menu.

To enable the developer mode set developer_mode=1 in the PYXLL section of the config file. See the config file documentation for more details.

In addition to the Reload menu item two macro commands are enabled, pyxll_reload and pyxll_rebind.

There commands can be called via Excel’s COM API, and so may be called from other processes outside of Excel which means they can be called by scripts invoked from an external editor.

pyxll_reload()

Reloads all modules listed in the PyXLL config file and updates all the Excel functions, macros and menus.

Calling this macro command is equivalent to selecting the Reload menu item.

pyxll_rebind()

Refreshes all the Excel function, macro and menu bindings. This can be used if additional modules have been imported since PyXLL started, or if modules have been reloaded and those modules include Excel functions that need to be updated to refer to the reloaded instances of the Python functions.

The are Excel macro commands, not python functions.

They may be called from VBA using the Run command, or from Python using the win32com module.

Example of calling from VBA:

Sub ReloadPyXLL()
        Run "pyxll_reload"
End Sub

Example of calling from Python (this may be called from any Python instance, not just from within Excel):

import win32com.client
xl = win32com.client.GetActiveObject("Excel.Application")
xl.Run("pyxll_reload")

See the developer tools examples for more information.

Debugging

It should be possible to use any remote Python debugger to debug code running in Excel using PyXLL.

If you are using Eclipse with PyDev you can use PyDev’s remote debugging feature to debug Python code in Eclipse. There is an example included with PyXLL that shows how, and is also available in the developer tools examples.