My friend Deane Yang pointed out returning invalid handles as 0 is not the Excel thing to do. Those get propagated down the line to dependent functions which then keep reporting errors. The right way to do it is to return std::numeric_limits::quiet_NaN()
instead. That shows up as #NUM!
in Excel and dependent calculations never get called.
I’ve added a class called xll::handlex
that is a replacement for HANDLEX and sets the default handle value to a NaN.