How to load/unload Word Add-in programatically?

前端 未结 1 581
天命终不由人
天命终不由人 2021-01-27 00:53

I\'d like to know how I can programatically load and unload a VSTO add-in in Word. I\'m using Word 2007 and VS2010 with C#.

I thought I might have some luck with using t

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-27 01:08

    I had similar requirement and achieved it by little cheat.

    I had a addin called AddinLauncher (with no ribbons) which will look for the user type and launch or closes the other addin.

    This code was called during AddinLauncher Addin Startup event.

    foreach (COMAddIn addin in Globals.ThisAddin.Application.COMAddins)
    {
      if (**specify your own condition**)
        {
            addin.Connect = true;
        }                       
    }
    

    The following changes are required in your deployment

    The Loadbehaviour for AddinLaucher addin is 3 and all the other addins are 0. More about Loadbehaviour here

    0 讨论(0)
提交回复
热议问题