We have developed a product that is a standard VSTO addin (Word 2010 and Word 2013, x86 only). By default when it is installed, it is installed for all users (ie. the addin registry entries are inserted into HKLM - HKEY_LOCAL_MACHINE\SOFTWARE\[Wow6432Node]\Microsoft\Office\Word\Addins
).
When the value for the LoadBehavior
reg key is set to 0x3
(i.e. "Load at Startup"), the addin works perfectly fine, however when we set the value for LoadBehavior
to 0x10
(i.e. "Load on demand"), the addin does not work as we would expect:
Due to UAC (and that Word does not run elevated), the value of LoadBehavior
in HKLM is not changed from 0x10
to 0x9
but instead is overridden by creating a LoadBehavior
key (with value 0x9
) in the HKCU hive.
Unfortunately, we have found that this HKCU overridden value is not taken into account unless the Manifest key is present in the HKCU hive along with LoadBehavior
). More info on this related thread: https://social.msdn.microsoft.com/Forums/vstudio/en-US/3776734b-333e-423b-9c08-7c7a441c3e94/load-behavior-and-word-addin?forum=vsto
The 'obvious' remedy for this issue is to write the Manifest
into HKCU for each user (as well as in HKLM) at install time OR when each user run the addin the first time. There are however some serious drawbacks with this approach:
Is it a bug that the manifest is not obtained from HKLM where the LoadBehavior
is set appropriately in HKCU? I think this issue would be resolved if the LoadBehavior
in HKLM could be overridden in HKCU without the need for the Manifest
value to be overridden as well.
Anyone knows of a way to overcome this issue?
On the File menu, point to New, and then click Project. In the templates pane, expand Visual C# or Visual Basic, and then expand Office/SharePoint. Under the expanded Office/SharePoint node, select the Office Add-ins node. In the list of project templates, select a Word VSTO Add-in project.
Deployment type If you want to register a VSTO Add-in to all users on a computer, you must use Windows Installer to deploy the VSTO Add-in. For more information about these deployment types, see Deploy an Office solution by using ClickOnce and Deploy an Office solution by using Windows Installer.
Right-click crmaddin. Addin, point to New, and then click DWORD Value or DWORD (32-bit) Value. Type LoadBehavior and then press ENTER. Right-click LoadBehavior and then click Modify.
You may get “Error loading add-in” while trying to install SmartCite in Microsoft Word 2016+ from the Store. This is due to an authentication issue, but not to worry - it's an easy fix! To get this solved, you need to log-out of Microsoft and log back in again.
Short of setting the UAC to "Never Notify," I do not know of a way to overcome your issues directly. However, I am going to suggest a workaround that will allow you to essentially Load on Demand.
I suggest that you change your VSTO addin'sLoadBehavior
to 0x0
(Unloaded - Do Not Load Automatically) and then use a VBA command in an automatically loaded template to control when your add-in loads. Here is an outline of the steps to take:
.dotm
). Using the Custom UI Editor for Microsoft Office embed within this template the XML for a ribbon tab that is labeled and positioned the same as the one from your add-in. Define the namespace in the XML the same as the one in your Visual Studio XML code so that they share the same namespace. Also, define a button that will load your addin (and perhaps do additional functions within your addin as well). Within your Template write a sub to load your unloaded 0x0
addin using this code:
Application.COMAddIns(ProgID).Connect = True
ProgID
is either the item idex of your ProgID or the actual name of the ProgID in quotes.
Within your template write a callback that will call the code to load the addin from the button.
Place the template in Word's STARTUP directory. For Word 2010 that is C:\Program Files (x86)\Microsoft Office\Office14\STARTUP
What we want to happen is that when Word is launched the VSTO addin is installed but is not loaded. The template you created IS loaded automatically from the STARTUP directory and places the ribbon tab for your application within Word. Because the VSTO addin is not loaded, those controls are not currently visible. However, after implementing the steps above, when the button from the template's XML is clicked, your addin will load its controls onto the same ribbon because they share a namespace. And when Word is closed and re-launched, it resets to the VSTO addin being installed but not loaded.
Taking this a step further, if you wanted to avoid the extra click of loading the VSTO addin controls, you could conceivably recreate the VSTO addin's XML within the template and have each control call code to load your VSTO addin, hide the template's ribbon controls, and perform your addin's functionality. In this way you would have your placeholder ribbon provided by the template's XML and the real addin loading and performing actions on demand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With