I'm making a VSTO Addin for PowerPoint in C#, which adds a better project explorer. I've been making it in a userform, however it would be better if the window would be part of the VBE editor (aka dockable). I found the CreateToolWindow function in Application.VBE.Windows.CreateToolWindow. However, I don't know how to use this function, or if it even does what I'm trying to do. The docs say very little about it and I couldn't find any examples on the internet. How do I get the Addin instance? What is ProgId? What is a UserDocument?
This is my base code:
namespace PowerPointAddIn1
{
public partial class ThisAddIn
{
public static PowerPoint.Application App;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Application.VBE.Windows.CreateToolWindow(/*...*/);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
VSTO add-ins are not designed for customizing the VBA editor. It seems you need to develop a COM add-in for the Visual Basic for Applications editor, not PowerPoint. To get that done you need to implement the
IDTExtensibility2interface. Typically your implementation will haveGuid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")andProgId("YourAddins.UserControlHost")attributes for the class (which implements the COM add-ins interface).ThisAddinis your add-in instance (usethisin C#). Typically when you implement theIDTExtensibility2interface the instance is passed as a parameter to theConnectmethod.This is a name of your add-in. Typically you can find it in the windows registry or in the
ProgIDattribute specified for the add-in class.The document that should be displayed in the editor.
You may find the sample code in the Create a toolwindow for the VBA editor with .NET(C#). article.