Hi,
Thanks for writing back with more details.
* I've yet to try your code under Excel 2013 (it seemed to work fine
under my Excel 2010).
* Can you give some indication of how often the xlfDialogBox call
fails - is it about 50% if the button presses, more often or rarely?
Does it matter which workbook is active when you press the button,
e.g. the first workbook in the Excel session might behave differently?
* Instead of triggering the macro from a ribbon, could you start it
directly from the Alt+F8 dialog box (you'll have to type in your macro
name, then the 'Run' button will become available)? This setting
differs in that it removes the ribbon, and Excel-DNA's RunAsMacro
helper from the equation.
* I think there is a dialog sample somewhere in the Excel XLL SDK.
I'll try to compile it into a working .xll and post it somewhere
online for you to test.
-Govert
On Mar 19, 3:19 pm, Koustubh Moharir <
koustubhmoha...@gmail.com>
wrote:
> Hi Govert,
>
> Firstly, thanks for replying and for your incredibly useful work!
>
> I tried your suggestion by adding the following code
>
> if (callResult == XlCall.XlReturn.XlReturnFailed)
> XlCall.Excel(XlCall.xlcAlert, "Things went wrong...");
>
> Now I either get my intended dialog or the alert. Always. So the other
> calls are indeed going through correctly.
>
> I also tried putting the call in an infinite loop until it succeeds. Most
> times, it succeeds within 5 attempts, but if it doesn't, it gets stuck in
> the infinite loop. If I exit the loop manually from the debugger, it
> typically succeeds the next time within 5 attempts.
>
> I can't think of a reason why the dialog would fail intermittently but the
> alert would succeed (since they both do similar things).
>
> I don't have the necessary skills to implement a native C xll at this
> point. So I might resort to setting up a timer event on Excel's UI thread
> and retrying the call there.
>
> Many thanks for your support.