2

I am creating an PowerPoint VSTO addin and that adds content to the active slide. When that content gets selected i want to show a settings task pane on the right side of the screen. I know that this can easily be done with an office web add-in but is it possible to do it in a VSTO add-in?

How can i add a custom task pane in an Office VSTO add-in using C#?

Im using Visual Studio 2019 and Office 2016

1 Answer 1

2

You should create a user control. Put some UI controls( in the solution I put a textbox and a button ) on that user controls as well as event handling. On the startup, ThisAddin adds the user control to the custom task pane.

Check out the sample solution I created on the following link PowerPoint Snap-In

… or use the following snippets. In ThisAddin.cs add two privates, one of type CustomTaskPane and the other of UserControl.

    // User control
    private UserControl _usr;
   // Custom task pane
    private Microsoft.Office.Tools.CustomTaskPane _myCustomTaskPane;

Create the user control. From the Project menu, choose 'Add User Control'. Add some UI elements to the user control ( e.g. textboxes, buttons, etc. ) Finally, in ThisAddin_Startup event handler that is created automatically for you by choosing Office VSTO project types, add following lines.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            //Create an instance of the user control
            _usr =new UserControl1();
            // Connect the user control and the custom task pane 
            _myCustomTaskPane = CustomTaskPanes.Add(_usr, "My Task Pane");
            _myCustomTaskPane.Visible = true;
        }

The result is shown in the image below enter image description here

More about Office VSTO on this link Office Development in Visual Studio

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer! It would be great if you could provide the code snipped that adds the user control to the custom task pane in your answer, so that future readers do not need to download your zip file
@Tobias Hoefer thank you for voting and thank you for a suggestion which I accepted. Now the answer include the code snippet as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.