开发者

Enabling PowerPoint VSTO add-in by default

开发者 https://www.devze.com 2023-01-31 13:36 出处:网络
When I install my VSTO-based PowerPoint plugin, it always shows up in the \'disabled\' section and everytime I open PowerPoint - I have to manually enable it.

When I install my VSTO-based PowerPoint plugin, it always shows up in the 'disabled' section and everytime I open PowerPoint - I have to manually enable it.

How 开发者_开发技巧do I programmatically change this behaviour such that plugin is always enabled by default.


When you set an Office (VSTO) addin to be enabled (in Office), it changes the registry key:

HKLM\SOFTWARE\Microsoft\Office\PowerPoint\Addins\YourAssemblyName "LoadBehavior"

The LoadBehavior value must be set to 3 to load (ie enabled) (2 is for disabled)

Office programs normally only change this LoadBehavior setting back to 2 when something goes wrong (eg exception in your Startup event code, failed to find an assembly etc) So you need to figure out what's happening (debug your Startup or do some logging)

In any case, to programatically set this, you'll need to write some code to change this registry setting.

I do it in an installer, using NSIS, for example:

StrCpy $0 "SOFTWARE\Microsoft\Office\PowerPoint\Addins\YourAssemblyName"

WriteRegStr HKLM $0 "Description" "Product Name"
WriteRegStr HKLM $0 "FriendlyName" "Product Name"
WriteRegDWORD HKLM $0 "LoadBehavior" 3
WriteRegStr HKLM $0 "Manifest" "$INSTDIR\YourAssemblyName.vsto|vstolocal"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号