Reloading an Excel Addin Programmatically - c#

I have an excel plug in that has a number of features. I have a button on the ribbon titled "configuration settings" that allows the user to select whether or not to allow some options (whether to include a right click menu, or to display some buttons on my ribbon).
The only way that I know to define a right click menu or to design the ribbon is in the start up of the excel addin.
I have a config file that gets checked on load, but should the user change the configuration using my ribbon button, it has no effect until excel is re-opened or the user manually reloads the addin. Is there a way to do this programmatically?

Probably you could have two addins. (Addin1, Addin2)
First addin (Addin1) which doesnt have any ribbons but reads the configuration and then enables another addin (Addin2).
To enable the addins use the following piece of code.
foreach (COMAddIn addin in Application.COMAddIns)
{
if (addin.ProgId.ToLower().Contains("addin2") && addin.Connect != true)
{
addin.Connect = true;
}
}

I don't think you can reload an Add-In from inside the same Add-In.
I tried it on my own - just unloading has worked for me.
But the buttons of a custom ribbon (e.g. named "Ribbon1") can be changed at runtime by accessing its properties via the "Globals" object:
Globals.Ribbons.Ribbon1.myRibbonButton.Visible = false;
Hope it helps,
Jörg

Related

VSTO Outlook Add-In published with load on demand inactive despite being loaded

I have a C# VSTO Outlook (2016) Add-in published as load on demand. The Add-in create a custom ribbon button when creating a new appointment.
When I load Outlook and open a new appointment the ribbon button is not displayed. The Add-in is checked when I go to COM add-ins menu in the developer ribbon but the status is load on demand (not loaded at the moment). In the File -> Options -> Add-ins, it is listed in the inactive section. LoadBehavior is set to 9 in the registry which I believe is what it shoud be after the first time.
When I unchecked the Add-in in the COM Add-ins menu, click OK, re-open, the COM Add-ins menu and check the Add-in again, the custom ribbon button reappear correctly so the code is working properly.
I set the add-in as load on demand otherwise it is always disable because of slow loading time despite having an empty ThisAddIn_Startup function. I assume it is because of the loading of the .net runtime as I have seen in other posts.
Also, I don't need the add-in loaded at startup as I only need the button when creating a new appointment. If possible, I would prefer avoiding modifying the registry and set the loadbehavior to 3 to force outlook to load the add-in.
Any ideas on how I could achieve that?
I set the add-in as load on demand otherwise it is always disable because of slow loading time despite having an empty ThisAddIn_Startup function. I assume it is because of the loading of the .net runtime as I have seen in other posts
Not always .net runtime. Your add-in instance must be created by the VSTO loader, so when an instance is created all dependent assemblies and components are loaded/created. You may re-think what dependencies are used in the add-in to decrease the required time for that. Note, you could initialize them at a later stage. For example, in case of Outlook, consider using the Application.Startup event which is fired when Microsoft Outlook is starting, but after all add-in programs have been loaded.
Also, I don't need the add-in loaded at startup as I only need the button when creating a new appointment.
Ribbon controls are requested by Office applications when the window is created and loaded. In that case it makes sense to have the add-in loaded at startup. The IRibbonExtensibility.GetCustomUI method is called by Office applications, typically it loads the XML markup, either from an XML customization file or from XML markup embedded in the procedure, that customizes the Ribbon user interface.

Outlook Form Region as a new window

I am creating a new VSTO add-in for Outlook 2013 & 2016. I have setup a Ribbon (XML) with a button that fires an event, which eventually opens a standard WinForm. The design (Ribbon location, menu, popup window size & location, etc...) is based off the "Signatures" ribbon button under "New Message".
Everything is fine and dandy until I realized that some of the features I want needs Outlook-specific controls. Adding them to my project's toolbox, I found out that they can only work on Outlook Form Regions, and not standard WinForms. I am able to get this to work with the standard FormRegion under the "New Message", but this is not desired behavior. Instead, I would prefer to have it pop up much like the standard "Signature" panel.
I would prefer solutions in C#/VSTO. If a solution would require a third-party alternative to VSTO, I would rather implement this in C++ instead.

How to position a newly added Add-On in the outlook

I have created a new add-on for Outlook and I created a setup file aslo. while installing my Add-On, The ribbon appearing in the last. I want to position it first. Please help...
You can change the order of custom tabs on a Ribbon by using the Tab Collection Editor
Click here for more details

How to programmatically remove a menu context item in Outlook 2013

I have an Outlook add in that was written with Outlook 2010 in mind but I am updating to handle Outlook 2013 correctly. As part of the add in I have included a number of context menu buttons using the IRibbon method.
At this point these new menu items work correctly, however I wish to remove one of the default Outlook contxt menu buttons with right clicking on a mail item or document in a specific folder.
I have tried declaring a GetVisible event for the button in the Ribbon XML but this does not get fired like the GetVisibile calls I have for my new custom added buttons.
If anyone has any hints, tips or experience with disabling one of the default Outlook 2013 context menu options they would be much appreciated.
Having looked into this further, the "Delete" option I was looking to remove was a new addition on 2013, having originally thought the add in I was working with had removed it in 2010.
It shares the same behaviour as the "Delete" button in the main top ribbon and appears to be a menu item that cannot be removed on an item type basis, but you can suppress the behaviour of the button within the add in.

Custom Ribbon in VSTO Addin for Outlook 2010 doesn't display

I've got a minimal VSTO Addin for Outlook 2010 with a ribbon. My only goal is to display a ribbon (created via designer) with no functionality. From what little I can tell from MSDN ribbons should just automatically be displayed by default, perhaps with tweaking ControlIdType/CustomId properties for tabs.
Alas, tweaking these properties does nothing -- Outlook loads and displays no tab. A simple message box displayed in the ribbon loader reveals it never is triggered. Additionally, I haven't seen any information resources (tutorials, walkthroughs, overviews, etc..) that say anything about needing to manually tell Outlook to display tabs.
How do I get the tabs displayed?
Is there a good resource other than MSDN that's good for VSTO newbies?
To get your ribbon displayed, on the base ribbon in your code change the RibbonType property to be Microsoft.Outlook.Explorer.
What fixed it for me (without starting a new project), in the Ribbon1.vb ribbon design, I clicked on the the Ribbon1 name above the ribbons 'File' button, in the properties pane, clicked on tabs (collection), under the heading 'Design' I changed the name (from Tab1) to something else.
Clicked ok, tested by clicking F5 and it worked. Hope this helps someone else.

Categories