windows form - Excel COM add-in

Add-in Express™ Support Service
That's what is more important than anything else

windows form - Excel COM add-in
windows form 
Francois




Posts: 14
Joined: 2014-03-18
I created a windows from for a COM excel add-in. But I can't find a tutorial (like this one for task panes: http://www.add-in-express.com/creating-addins-blog/2013/10/08/creating-custom-task-panes-excel/#taskpanes) to link the windows form to my add-in.

I hope someone can list the the steps required to do that.

Any help will be greatly appreciated,

Thank you.

Francois
Posted 19 Mar, 2014 13:40:06 Top
nwein




Posts: 577
Joined: 2011-03-28
You can't use a form in your COM add-in, only a User Control.
You can of course, launch forms from your add-in but that is not the same thing.
What are you trying to achieve? a task pane? advanced task pane?
Each one has different way of implementation, but none uses Windows Forms.
Posted 19 Mar, 2014 14:32:33 Top
Francois




Posts: 14
Joined: 2014-03-18
I would like to display a form from my add-in, so the user can add some inputs parameters for a simulations.

I used task panes in the past, so I would like to do something different like use a form.
Posted 19 Mar, 2014 14:39:39 Top
Francois




Posts: 14
Joined: 2014-03-18
What are the steps involved to show a windows form from a COM add-in?
Posted 19 Mar, 2014 14:54:56 Top
nwein




Posts: 577
Joined: 2011-03-28
Nothing special really. You just do a myForm.Show() to show the form.
With that being said, the form is not modal and might be hidden behind Excel.
you can show a dialog which will guarantee it's modal, but then you're blocking access to Excel which is not something most users (and Excel) like.
Alternatively you can set the TopMost property of a modaless form to be true so you're achieving something similar to Excel's own dialogs.
Regardless of your choice, either way is as simple as calling the Show() or ShowDialog() methods.
Posted 19 Mar, 2014 16:04:28 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Thank you Nir!

Hello Francois,

The problem with non-modals is they usually interfere with the windowing of the host application. A from hidden behind the host application's window is just an example. Typically, affected can be tooltips on your form; keyboard shortcuts - Excel may intercept them; focus issues are possible too. For these reasons, we recommend showing the form modally. If the logic of your add-in requires using a non-modal form, consider using a pane instead.


Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2014 01:29:48 Top
Francois




Posts: 14
Joined: 2014-03-18
Is this why when I click Add-in express "Add New Item" (under XCell Tolls) there is no "userform" to choose, only "ADX Excel Task Pane"?

Is there a way to do like in VBA "insert a user form"?

Thank you,

Francois
Posted 20 Mar, 2014 08:08:07 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Francois,

I suggest that you describe what you need to achieve. Is this possible? I've read the above. Why would you need to use a form?


Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2014 08:27:31 Top
Francois




Posts: 14
Joined: 2014-03-18
I built an Excel add-in in VBA, and I am rebuilding it in Visual studio using Add-on express. In VBA it is easy to use a form to get unput from user or output things like graphs.

I would like to build something similar to this using Add-on express.:

User added an image

Is it possible?

Thank you for your help,

Francois
Posted 20 Mar, 2014 08:55:55 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Francois,

You cannot use VBA UserForms in .NET. You have two possibilities:
- use a modal form
- use a pane

Which of them to use, you need to decide for yourself: you know how you want the user to use the controls. One suggestion though. It is possible that you choose one way now and opt for another way later. To simplify switching, you can add your controls onto a UserControl. This would let you just copy the UserControl from a form onto a pane.


Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2014 09:32:29 Top