How to use a dialog in an Excel shared addin

Posted by user169867 on Stack Overflow See other posts from Stack Overflow or by user169867
Published on 2010-05-14T20:47:56Z Indexed on 2010/05/15 17:54 UTC
Read the original article Hit count: 294

Filed under:
|
|
|
|

I'm writing a shared addin for Excel. It adds a CommandBarButton that when clicked opens a WPF window to collect some information from the user.

I wanted to keep the same WPF dialog in memory and reuse it so that if the user clicks the CommandBarButton again their previous values would still be there.

So I made a reference to my WPD as a private member of my addin object that implements Extensibility.IDTExtensibility2.

I created the window during OnStartupComplete(), but for some reason when I run Excel the window immediately opens even though I never called ShowDialog() and when I do call ShowDialog() when the CommandBarButton is clicked to reOpen the window it fails to load.

Does anyone know why this happens and what the correct way to handle this is?

Thanks very much for any help.

© Stack Overflow or respective owner

Related posts about vsto

Related posts about c#