Call this when you want Excel to do some work
This adds the corresponding delegate onto the Excel queue.
This method does not run the delegate that you pass in.
It just adds it to the queue or work and returns immediately.
The delegate is only run when Excel becomes idle.
In an Excel-DNA add-in, all access to the Excel COM object model should be from the main Excel thread. (A call to ExcelAsyncUtil.QueueAsMacro will allow you to initiate code running in a safe context on the main thread, from any other thread or context.)
Your Excel-DNA add-in should have no calls to Marshal.ReleaseComObject or Marshal.FinalReleaseComObject

link - andysprague.com/2017/07/03/show-message-boxes-with-excel-dna/

    ExcelDna.Integration.ExcelAsyncUtil.QueueAsMacro( ()=> 
       ExcelReference activecell;
       activecell = (ExcelReference)XlCall.Excel(XlCall.xlfActiveCell);

       ExcelDna.Integration.XlCall.Excel(xlCall.xlcSelect, activecell);

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext