Debugging
Every call to JuliaCall/JuliaCallVBA/JuliaEval/JuliaEvalVBA leaves a trace behind in Julia, so a problem can be debugged at the REPL without needing to repeat the call from Excel:
CallFromExcel.last_questionis the expression that was evaluated - either the exact string passed toJuliaEval/JuliaEvalVBA, or, forJuliaCall/JuliaCallVBA, a reconstructed call such asmyfunction(CallFromExcel.args_from_xl...). A call of your own worksheet function,=jl.myfunction(...), appears in the same way, withargs_from_xlas the function receives them (vectors for arguments declared::AbstractVector, and so on). A formula creating a handle appears as a call ofCallFromExcel.handle_create(orhandle_create_exposed, for a function exposed withhandle=true), whose first argument is the name of the function it calls (the Excel name, forhandle_create_exposed).CallFromExcel.last_answeris the value that was returned to Excel or, if the call failed, the message Excel was sent.CallFromExcel.args_from_xlholds the arguments most recently passed from Excel toJuliaCall/JuliaCallVBA, or the positional arguments forJuliaCallNamedArgs/JuliaCallNamedArgsVBA. For those,CallFromExcel.kwargs_from_xlholds the named arguments as aNamedTuple, andlast_questionis a call such asmyfunction(args_from_xl...; kwargs_from_xl...).CallFromExcel.answer_again()evaluateslast_questionagain, and you can wrap it with@enteror your own debugging tools.
All of these only reflect the most recent call, so debug before making another one. Call CallFromExcel.display_results(true), or tick Display Results on the ribbon, to also have each call and its result echoed to the Julia console as it happens.
For handles:
=JuliaHandleInfo("count")shows how many handles worksheet formulas hold, and how many objects Julia stores. If Julia stores more than the formulas hold, the difference is handles created from VBA and not yet released.=JuliaHandleInfo("events")lists recent creates and releases, newest last - for example, to see whether a formula creates a new object at every recalculation.=JuliaHandleInfo("objects")lists every object Julia holds, with its handle and its size in bytes - for example, to see which handles use the most memory.- The ribbon's Rebuild Objects button rebuilds every handle's object, as happens when Julia restarts. From VBA,
Application.Run "JuliaRebuildObjects"does the same.
To step through your code with a debugger, attach a Julia session you already have open, such as one in VS Code - see Attaching to a running Julia session.