Re: ExcelDNA async callback to VBA method

562 views
Skip to first unread message

Govert van Drimmelen

unread,
Feb 11, 2013, 4:15:57 AM2/11/13
to Excel-DNA
Hi Kieran,

You should be able to call it with
ExcelAsyncUtil.QueueMacro("MyMacro") or else you can put the code the
runs it into ExcelAsyncUtil.QueueAsMacro(delegate { ...}).
(Be sure to call ExcelAsyncUtil.Initialize() in an AutoOpen if you
want to do this.)


Add-ins based on different versions of the .NET runtime should not
interfere.

If two add-ins have functions with the same name, the last one loaded
will win.

Regards,
Govert


On Feb 11, 10:32 am, knaier <kieran.russell.sm...@gmail.com> wrote:
> Hi everyone,
>
> Apologies if this has been asked before but i can't find a working example
> for what i'm trying to achieve.
>
> What i need to do is from 3.5 C# call back to Excel macro in a safe way,
> i.e. if the window is not active either send it to the correct application
> or wait until the window has focused again and queue the async calls.
>
> Is this possible?
>
> Any suggestions for this would be much appreciated.
>
> FYI - in Managed XLL this would be handled by extending ExcelAsyncOperation
> which allows you to make callbacks to Excel in a safe way.
>
> Also does anyone know if it's possible to have a 3.5 DNA XLL and a 4.0 DNA
> XLL running side by side in the same Excel session?
>
> Also what happens if 2 addins have the same function, which is active?
>
> Thanks!
>
> Kieran

Govert van Drimmelen

unread,
Feb 11, 2013, 9:08:14 AM2/11/13
to Excel-DNA
Hi Kieran,

Maybe try something like:

ExcelAsyncUtil.QueueAsMacro(delegate {
dynamic xlApp = ExcelDnaUtil.Application;
xlApp.Run("MyMacro", param1, param2);
});

-Govert

On Feb 11, 3:35 pm, knaier <kieran.russell.sm...@gmail.com> wrote:
> Thanks again Govert! :)
>
> This works when there are no arguments to the macro. However, we need to
> make a callback with 2 arguments, is this possible?
>
> Thanks,
>
> Kieran
Reply all
Reply to author
Forward
0 new messages