AnsweredAssumed Answered

VB.NET Add In - Use One(1) Button for all Document Types to Launch a User Form

Question asked by Checkcheck Master on Mar 18, 2016
Latest reply on Mar 19, 2016 by Checkcheck Master

Hi there,


Coming from VBA trying to get my fingers behind VB.NET boosted by a friendly guy who wrote a beautiful tutorial how to create a VB.NET add in which opens a user form.

Check it out at and count your smiles at:

JellyWorks: Taking your SolidWorks VBA macro to the Add-in Realm


My question:

In the VB.NET macro a menu and menu button can be created with 'AddMenu' and 'AddMenuItem' which will be present in the SW UI under 'Tools'.

I like to launch the macro by pressing a keyboard button, this is possible by creating a shortcut for the added 'AddMenuItem', no problem till so far

But now i like to make it possible to launch the macro with just one(1) keyboard button for all document types like Parts, Assemblies and Drawings.

Unfortunately you have to specify for which document type the button will be valid and then the shortcut only works for that document type.


For example:

menuId = SwApp.AddMenu(swDocumentTypes_e.swDocPART, "MyMenu", 0)    menuId = iSwApp.AddMenuItem5(swDocumentTypes_e.swDocPART, addinID, "MyMenuItem@MyMenu", 0, "MyMenuCallback", "MyMenuEnableMethod", "My menu item", images


Does anybody know how to code a button that wil be valid for any document type so that the shortcut will always work ?

The macro itself determines what kind of document type we are dealing with and which action will take place.


Thanks anyway!