OnStartupComplete not working?

36 views
Skip to first unread message

Oscar Peters

unread,
Sep 24, 2023, 4:38:24 AMSep 24
to Excel-DNA
Hi all,

I am trying to run some code and show a message after the the addin has loaded. I have implemented https://excel-dna.net/docs/guides-advanced/detecting-excel-shutdown-and-autoclose/#example-add-in to the letter, using the exact code as provided in the example. All methods but OnStartupComplete show their message. Unfortunately that is the event I need for my prupose. What am I missing?


KR. Oscar

Govert van Drimmelen

unread,
Sep 24, 2023, 4:53:53 AMSep 24
to exce...@googlegroups.com

Hi Oscar,

 

I think the COM add-in you are loading, is loading after Excel has complete its ‘startup’.

The IDTExtensibility2 interface that the COM add-ins implement is quite generic, so different application might use it differently.

I suspect a ‘normal’ (non-xll based) COM add-in that is registered with Excel will have an initialization while Excel starts, and might then have OnStartupComplete called after that.

But for our case it’s hard to know where in the Excel ‘startup’ sequence the .xll AutoOpen runs, and when the COM add-in loads.

 

Why is this event interesting to you?

Perhaps you can get use OnConnection event, or I can suggest another plan.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/590daa28-f053-4ef1-adfa-27b6c5d8e214n%40googlegroups.com.

Oscar Peters

unread,
Sep 24, 2023, 5:45:23 AMSep 24
to Excel-DNA
Hi Govert,

Thanks for the very quick reply on this Sunday :-).

The reason I want to use this event is that I want to show a dialog everytime the addin loads (or better: has finished loading). For arguments sake - because I want to let the user know that their authorization did or did not validate. The options I have explored all mean that the dialog is shown during the loading process of the addin.

I would be curious about the other plan that you can suggest.


KR. Oscar
Op zondag 24 september 2023 om 10:53:53 UTC+2 schreef Govert van Drimmelen:

Govert van Drimmelen

unread,
Sep 24, 2023, 5:57:26 AMSep 24
to exce...@googlegroups.com

--------------------------------------------------
Enjoying our project?

Consider supporting its continued development by becoming a GitHub Sponsor.

Your help ensures we can keep improving and assisting you.

--------------------------------------------------

 

Hi Oscar,

 

You can queue some work to run after the load is complete, by using ExcelAsyncUtil.QueueAsMacro like this

 

    public class AddIn : IExcelAddIn

    {

        public void AutoOpen()

        {

            ExcelAsyncUtil.QueueAsMacro(() =>

            {

                Excel(xlcAlert, "Hello from after the add-in load!");

            });

        }

 

        public void AutoClose()

        {

Govert van Drimmelen

unread,
Sep 24, 2023, 6:00:45 AMSep 24
to Excel-DNA
I should add this 'using' at the top of the code:

    using static ExcelDna.Integration.XlCall;

-Govert

Oscar Peters

unread,
Sep 24, 2023, 6:41:58 AMSep 24
to Excel-DNA
Thanks for the example, but my requirement is a bit more complicated than that.
I want to display a custom system.windows.form dialog after load/startup. Any suggestion for that?

Op zondag 24 september 2023 om 12:00:45 UTC+2 schreef Govert van Drimmelen:

Govert van Drimmelen

unread,
Sep 24, 2023, 5:15:02 PMSep 24
to exce...@googlegroups.com

Hi Oscar,

 

If you want to show a modal dialog, you can run that from the ExcelAsyncUtil.QueueAsMacro.

If you need a dialog that stays around, I would suggest making a Custom Task Pane – that seems to integrate into the window handling a bit better.

Oscar Peters

unread,
Sep 25, 2023, 3:10:07 AMSep 25
to Excel-DNA
Hi Govert,

Thanks for the additional guidance.
I eventually solved it by putting the modal dialog on a different thread. This allows the loading of the addin to finish while still displaying the dialog, waiting for user action.

Keep up the good work with ExcelDNA!

KR. Oscar

Op zondag 24 september 2023 om 23:15:02 UTC+2 schreef Govert van Drimmelen:
Reply all
Reply to author
Forward
0 new messages