Thanks, Govert!! I can confirm that going through the COM interface
removes the 256-character restriction. However, performance isn't
nearly as good as XlCall.RTD(), so I'll stick with the workaround I
mentioned above. Let me know if you want me to test anything that
might remove the 256-character limit on XlCalc.RTD().
I'm getting some strange performance issues with XlCalc.RTD as well.
Let me explain:
I'm trying to pass a string back from RTD, explode it in the UDF and
return it as an array. I have IsMacroType set to true because
otherwise the UDF returns #VALUE if the selection is an array. It is
extremely responsive when the selection range for the UDF is under
5-6k cells large. The size of the RTD string and returned array
doesn't matter, so performance is just as fast if the RTD/UDF is
returning a 20k-cell array or a 2k-cell array. However, when I select
a 12k-cell output array for the UDF (2 columns, 6k rows), CPU usage
spikes to 100% for 5-10 seconds. Again, it doesn't matter how big the
returned array is -- only how big the selected output for the UDF is.
So I could be returning a 1-character string or a 2x2 array of strings
and putting it into a 2x6k selection range, and it will hang for 5-10
seconds. The closest I can track down the performance issue is to
between when RefreshData returns the topic to Excel and the UDF is
called. What is also interesting is if I return a 12k-cell array into
a single cell selection, it is blazing fast. Then if I enlarge the
selection to 12k cells (hit F2 on the cell with the UDF, enlarge the
selection to 12k cells, then hit cntl-shift-enter), it is also blazing
fast. However, going straight to the 12k selection, I get the 5-10
hang. And, either way, if the UDF has to be recalculated, I get the
performance hit.
The only time I get this odd performance problem is when XlCalc.RTD()
is in the UDF. I can return a 100k cell array into a 100k selection
without a problem if there is no RTD call in the UDF. This, and the
other tests I have done, makes me think that this is an issue with how
Excel triggers a wrapper UDF call after RefreshData() returns results
for a topic tied to the UDF. It looks like Excel is doing some
calculations that depend on the size of the selection of the UDF. I
have no idea how to dig deeper into the process, though.
A hack I have experimented with involves using a macro like Ozzie's
TidyArray to make the UDF's selection range smaller when the UDF is
first called, and then expand it after the result are set. This is
really ugly but actually works very well for when the UDF is first
created. However, if the UDF needs to re-run because its inputs
change, it's hard to shrink it before RefreshData() is called in a
consistent way.
Let me know if you have any ideas on the RTD->array performance issue,
and if you want me to run any tests on the 256-character restriction
issue.
Thanks a lot for the help!
Best,
Serge