none
How to resize task pane Word 2013/VS 2013 RRS feed

  • Question

  • I created Word Add-in using VS2010/VSTO2010. It contains a ribbon toggle button that shows/hides a custom task pane. My task pane title is a little longer than would fit in the default width of the task pane so I made it a wider using:

    Public Sub RibbonTBOnAction(ByVal control As Office.IRibbonControl, pressed As Boolean)
            Select Case control.Id
                Case "tbTest1"
                    If pressed Then
                        bTBTest1Pressed = True
                        Globals.clsThisAddIn.TaskPane.Visible = True
                        Globals.clsThisAddIn.TaskPane.Width = Globals.clsThisAddIn.TaskPane.Width + 20
                    Else
                        bTBTest1Pressed = False
                        Globals.clsThisAddIn.CustomTaskPanes(0).Visible = False
                    End If
            End Select
        End Sub

    It worked fine.  The task pane would show at the expanded width and hide seamlessly.

    Today I attempted the same thing using VS 2013 and the VS Office Developer Tools 2013.  Using the same code.  Now there is a noticeable anomaly.  When I toggle the task pane to show it shows at the default width, then collapses, then shows again at the expanded width.  While it works, it is clearly noticeable and would be annoying to a user.

    I tried move this line:

    Globals.clsThisAddIn.TaskPane.Width = Globals.clsThisAddIn.TaskPane.Width + 20

    to before the .Visible = True line

    but then the task pane is displayed much narrower than the default width.

    What is the correct way to show a taskpane wider than the default width?

    Thanks


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Friday, November 28, 2014 2:46 PM

All replies

  • Hello Greg,

    I see the following two statements in the code:

    Globals.clsThisAddIn.TaskPane.Visible = True
    Globals.clsThisAddIn.TaskPane.Width = Globals.clsThisAddIn.TaskPane.Width + 20
    

    Try to remove the Visible property setter, leave only the Width setter. Does it help?

    Saturday, November 29, 2014 4:12 PM
  • Eugene,

    Leaving only the width setting and the TaskPage doesn't show.  I did try and at least the TaskPane now shows on my PC at the proper width (wide enough to show the full title).  But I'm not sure I would look right on every PC.  I don't understand why what I had done (and that might have been incorrect as well) with VS2010 isn't working now.  Seems there should a property to autosize the width of the task pane to display its full title/content.  Thanks for replying.

    'Globals.clsThisAddIn.TaskPane.Width = 500


                       

    Globals.clsThisAddIn.TaskPane.Visible = True


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Saturday, November 29, 2014 4:29 PM
  • Okay. Try to set the Visible property after changing the Width property, for example:

    If pressed Then bTBTest1Pressed = True Globals.clsThisAddIn.TaskPane.Width = 500

    Globals.clsThisAddIn.TaskPane.Visible = True Else ...


    Saturday, November 29, 2014 4:49 PM
  • Eugene,

    Yes, that is what I did and it looks ok on my PC, but what if someone with a much smaller screen used the addin.  Wouldn't the taskpane then be much too wide.  In hindsight, ever the method I used with the 2010 addin that seemed to work, probably wouldn't have work universally.

    I guess the real question is how do you (if it can be done) autosize a taskpane so the entire taskpane is displayed.

    thanks. 


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Saturday, November 29, 2014 4:59 PM