Easy way to call a static excel dna function/macro from immediate widnow

138 views
Skip to first unread message

Kedar Kulkarni

unread,
Jul 15, 2020, 11:16:56 AM7/15/20
to Excel-DNA
I am looking for a simple way to call my public static parameterless void function (written in a static class) from immediate window for automating a certain task. I dont want to create a ribbon button as it is not to be exposed from UI.

I already have a ribbon. I tried to use  ExcelCommand but it did not show in addins ribbon. Is there a limitation of ExcelCommand that if we already have a ribbon setup, excel command does not work?

My Application.Run("Teste") did not succeed when I used example from https://stackoverflow.com/questions/48270611/how-to-use-excelcommand-from-exceldna  
I am just looking for a quick and dirty way to call my .net void function(equivalent to excel macro) from vba immediate window. May be I am missing some step. (using office 2016 + latest excel dna.) 

Kedar Kulkarni

unread,
Jul 15, 2020, 11:20:15 AM7/15/20
to Excel-DNA
I understand Excel command would create a ribbon but I am adding it under #if DEBUG so I assume it wont show in release mode.  (finally I might create a dummy ribbon id which will be visible only in debug mode if no other option.)

Govert van Drimmelen

unread,
Jul 15, 2020, 11:26:29 AM7/15/20
to Excel-DNA
I think Application.Run is the right plan for you, and should work if you have the name right.
If your command is registered with the name "MyTestCommand" as in the Stack Overflow example, you should call it as Application.Run("MyTestCommand") and not as Application.Run("Teste").
If the ExcelCommand overrides the method name as in this case, you use that new name in the Application.Run call too.

-Govert

Kedar Kulkarni

unread,
Jul 15, 2020, 12:20:36 PM7/15/20
to Excel-DNA
thanks-- that worked..
Reply all
Reply to author
Forward
0 new messages