Getting plain VSTO ActionsPane to work.


Adding programmable task pane aka ActionsPane with VSTO is a piece of cake. All you really need to do is just add controls to the ActionsPane object using the familiar WinForms paradigm. Here is how you would show a button on the task pane in Word.


Globals.ThisDocument.Controls.Add(new Button());


This code produces less than sofisticated task pane but if you remember to do this you are only "this" close to be the ActionsPane expert . If you need to construct something more fancy you do not write any code at all - you use the WinForms designer. Couple clicks to add new UserControl to your project, then couple drag&drops to design the UserControl and set all the right properties in the Property Browser (especially useful is setting the left and right anchors for the text boxes - then those text boxes can resize with the task pane). Then write this code in ThisDocument_Startup event handler:


Globlas.ThisDocument.Controls.Add(new MyUserControl());


if you still have not removed the code that adds the empty button then you should see the UserControl stack below the button. This automatic stacking is useful when you want to conditionally add/remove additional UserControls (e.g. you would like to display a currency converter when user fills in expenses part of the trip report - I know the scenario is lame but just bear with me for a moment [:)]).


Additionally your document just became a SmartDocument. It has an XML Expansion Pack (XEP) attached to it. Check out the Tools->Templates and Add-ins ... dialog. You will see that your document references ActionsPane.xsd schema (which is empty and is there because a schema is required to get whole SmartDocs mechanism get going) and has "Microsoft Actions Pane" XEP as well.


Here is a fun thing to try: delete the "Microsoft Actions Pane" XEP. It is hard to get rid of. It is not the case with other SmartDoc solutions, but this one seems to have an extra protection. Any insights on what is going on here?


P.S. I am making my posts shorter and aimed to deliver a short point and I am still on the fence whether this is the right thing to do. Is this better than cramming vacations and introductions into the same post? Or sacrificing the readability and delivering as much information as possible is gonna be more useful when people look for answers later?

Comments (16)

  1. Well, you can always "clean up" your posts later on.

  2. Mike Taube says:

    I don’t understand something: how come on a plain installation of VSTO 2005 with VSTO 2005 SE, I can’t get the ActionsPane to be recognized?

    I simply created a project of type C#/Office2003/Word AddIn

    I tried typing in the line exactly as you did, but there’s no ThisDocument: Only ThisAddIn.

    But ThisAddIn has no Controls property. And the ActionsPane property is nowhere to be found.

    When I try to add a user control of type ‘ActionsPane’ as some of the MSDN docs mention, it’s not there to choose from.

    This is killing me – do you know what I’m doing wrong?

    Thanks!!

    Mike

    mtaube@caci.com

  3. Mike Taube says:

    OK So I figured out that in order to get the ActionsPane to work as advertised, I had to uninstall both VSTO 2005 SE and VSTO 2005, and then reinstall just VSTO 2005. But the template type is ‘word document’.

    what if I want to create an add-in to modify the ActionsPane instead of a word document?

  4. Mike,

    ActionsPane is not something that is support for add-ins – only doc-level customziations get it. If you need to have a task pane available for add-ins I can suggest you to try CustomTaskPanes in Office 2007( sorry to tell you but there is no analogous feature for Office 2003).

  5. Kiran says:

    Actionpane control doesnot show-up in japanese OS in Office 2007:

    I have created VSTO based Office 2003 solution. Recently i have upgraded this application to Office 2007 support. For this i upgraded to VSTO SE. Everything is working fine so far.

    Today, I tested this Office 2007 application in Japanese Windows XP OS. Even though application is running fine, the actionpane control i created in application doesnot show-up in japanese OS.

    Can you tell me how to fix it, or are there any known issues between VSTO SE with Japanese OS.

    thanks,KK

  6. Marcela says:

    Hi Mike:

    When I run my office application in client machine, the ActionPane don’t show.

    I have the application installed in my machine and it´s work fine.

    I don’t know What happened because I have tried many solutions that I have found in Internet.

    Can you help me, please?

  7. Marcela,

    Can you find out whether this machine has the below registry key:

    HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerActiveX Compatibility{5f61f809-422a-4152-91f5-9ec1b935efd7}

  8. Marcela says:

    Mike,

    Thanks for your answer.

    Yes, it has that registry key.

  9. Ohh, this reg key is known as IE killbit and prevents ActionsPane from working correctly. We still have no idea what causes this reg key to appear on some machines and we have not been able to repro it internally either.

    Meahwhile you can  just delete it. Also see this post with some more details:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2290867&SiteID=1&mode=1

  10. Stefan Daugaard says:

    Hi Misha,

    Have you found any further explanation why the IE killbit reg key is sometimes added to the registry? We have had the same problem on some of our computers, and we don’t know why…

  11. No… so far this still remains a mystery.

  12. telekallis says:

    Thank you for the advice about the reg key. We have managed to solve the "Lost ActionPane"-problem at several customers by removing the specified key.

    However, we have this one specific client where all client computers display EXACTLY the behavior to be expected if the "killbit" is set, BUT…the reg entry does not exist on these machines!!!

    Do you know of any other known way that the ActiveX ActionPane can be "blocked" (as it is by the "killbit") apart from the killbit? Like by a firewall or a virus protector?

    Regards

    Kallis

  13. All, with the help of one of the readers we have confirmed the source of the killbit problem.

    It turns out that some international installations of Windows XP SP2 do install the killbit (I did suspect one of the security updates – but turned out this was way simpler than that). We have confirmed that installing Windows XP SP2 Czech OS do cause killbit to appear, but that is not the case with either US or German editions. Such inconsistency is the source of major problems for out developers where solutions mysteriouly do not work at customers sites.

    We did work with folks in Windows to get this issue addressed by publishing a global update removing this reg key but due to relatively easy workaround, the relatively old age of the OS itself and thus limited support scope – the update did not get approved.

    Instead, Microsoft we are planning to publish a KB article confirming the problem and also recommending to either remove the registry key during the setup or, if no custom setup of the solution is done e.g. when doc-level solution are deployed onto a server, then solution code can detect the presence of this registry key and inform the user that this key needs to be removed for the solution to work properly.

    Thanks a lot to Ernst for helping to troubleshoot this.

    Misha

  14. Erik Renes says:

    Hi Misha,

    Thanks for posting this solution, we invested about two man days worth of research into this problem until we stumbled upon your blog. Now the issue is resolved 🙂

    Best Regards,

    Erik

  15. Jus t letting everyone know that a KB article covering the killbit mystery has been recently published – http://support.microsoft.com/?id=971507

Skip to main content