Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7981919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:31:19+00:00 2026-06-04T10:31:19+00:00

I am trying to create a simple MS Word addin (mostly to explore functionality).

  • 0

I am trying to create a simple MS Word addin (mostly to explore functionality). The addin adds a Custom Task Pane, and group in the Ribbon. The Ribbon controls include a checkbox to control the visibility of the Custom Task Pane, and a button to open a document. When I test the addin in MS Word the task pane shows up correctly, and the checkbox works correctly. The problem is, as soon as I click the button and open a new document, the task pane is hidden, and the checkbox no longer controls the the task pane’s visibility. What is going wrong? How can I keep the custom task pane showing?

Here is a simple version of the addin:

public partial class ThisAddIn
{
    private MyUserControl _myUserControl;
    private CustomTaskPane _myCustomTastPane;
    private OpenFileDialog _dialog;

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        _dialog = new OpenFileDialog { Filter = "Doc File (*.rtf)|*.rtf", RestoreDirectory = true };
        _myUserControl = new MyUserControl();
        _myCustomTastPane = this.CustomTaskPanes.Add(_myUserControl, "My Task Pane");
        _myCustomTastPane.Visible = true;

        Globals.Ribbons.MyRibbon.ShowPane.Click += ShowClicked;
        Globals.Ribbons.MyRibbon.LoadDoc.Click += LoadFile;
    }

    private void ShowClicked(object sender, RibbonControlEventArgs ribbonControlEventArgs)
    {
        _myCustomTastPane.Visible = Globals.Ribbons.MyRibbon.ShowPane.Checked;
    }

    void LoadFile(object sender, RibbonControlEventArgs e)
    {
        if (_dialog.ShowDialog() != DialogResult.OK) return;

        object missing = Missing.Value;
        object myFalse = false;
        object myTrue = true;
        object format = WdSaveFormat.wdFormatRTF;
        object fileToOpen = _dialog.FileName;

        Application.Documents.Open(ref fileToOpen, ref myFalse, ref myFalse, ref myFalse, ref missing, ref missing, ref missing, ref missing,
                                                                ref missing, ref missing, ref missing, ref myTrue, ref myFalse, ref missing, ref missing, ref missing);
    }

    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    {
    }

    #region VSTO generated code
    //....
    #endregion
}

To keep things simple I’ve left out the definition of the ribbon, as it is really just a button and a checkbox. I’m also left out the definition of MyUserControl, as the content of the class isn’t really important (in my demo version I just have a simple class with a label).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:31:21+00:00Added an answer on June 4, 2026 at 10:31 am

    In MS Word, Custom Task Panes are per-document window (see MSDN Reference). If you open a new document, the Task Pane collection is different. If you want to keep a persistent task pane open – you would have to manage it yourself by monitoring document open/close events as stated below.

    From MSDN…

    When you create a custom task pane for Word 2007 or InfoPath 2007, the custom task pane is visible only for a single document. Task panes in these applications are associated with the window that hosts documents, but there is a different instance of this window for every document.
    …
    If you want to display a custom task pane for multiple documents, you can create a new instance of the custom task pane when the user creates a new document or opens an existing document. For example, you can create handlers for the NewDocument or DocumentOpen events in a Word 2007 add-in to create a new instance of your custom task pane that is visible with the new or opened document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a simple custom validator for my project, and I can't
I am trying to create a Word document with a very simple word macro.
I'm trying to create a fairly simple macro in Word 2010 using Visual Basic.
I'm trying to create create a simple word template on the fly which would
I'm studying webrat and cucumber and trying to create simple example. Here is my
Im trying to create a simple pan and zoom app using silverlight 4, but
Im trying to create a simple input box with form validation, but im not
I'm trying to create a simple Add-On for SQL Server 2008; it is simply
I am trying to create a simple Python module for MySQL Workbench 5.1.17 SE
I'm trying to create a simple example of an editable gridview, and for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.