1

I am making an Office add-in which has two ribbon buttons. Each button is linked to a different TaskpaneId, and clicking on each button opens a different taskpane:

<bt:Urls>
    <bt:Url id="Contoso.Taskpane1.Url" DefaultValue="https://localhost:3000/addin/page1" />
    <bt:Url id="Contoso.Taskpane2.Url" DefaultValue="https://localhost:3000/addin/page2" />
</bt:Urls>

It seems that I have seen some Office Add-ins where two task panes can be shown side by side simultaneously (I forgot which exactly the add-ins are). I need this from time to time, does anyone know how to realise this?

SoftTimur
  • 5,630
  • 38
  • 140
  • 292

1 Answers1

0

Script Lab is one such add-in. All you need to do is create two different buttons that have a ShowTaskpane action with different IDs.

Example from Script Lab's prod manifest: https://github.com/OfficeDev/script-lab/blob/master/manifests/script-lab-prod.xml

            <Control xsi:type="Button" id="PG.CodeCommand">
              <Label resid="PG.CodeCommand.Label" />
              <Supertip>
                <Title resid="PG.CodeCommand.TipTitle" />
                <Description resid="PG.CodeSupertip.Desc" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="PG.Icon.Code.16" />
                <bt:Image size="32" resid="PG.Icon.Code.32" />
                <bt:Image size="80" resid="PG.Icon.Code.80" />
              </Icon>
              <Action xsi:type="ShowTaskpane">
                <TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>  
                        <===== A taskpane ID. This one is a "special" one that allows the taskpane
                               to auto-open if a document is marked as belonging to the add-in.

                <SourceLocation resid="PG.Code.Url" />
                <Title resid="PG.CodeCommand.Title" />
              </Action>
            </Control>
            <Control xsi:type="Button" id="PG.RunCommand">
              <Label resid="PG.RunCommand.Label" />
              <Supertip>
                <Title resid="PG.RunCommand.TipTitle" />
                <Description resid="PG.RunSupertip.Desc" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="PG.Icon.Run.16" />
                <bt:Image size="32" resid="PG.Icon.Run.32" />
                <bt:Image size="80" resid="PG.Icon.Run.80" />
              </Icon>
              <Action xsi:type="ShowTaskpane">
                        <===== Whereas this one dosn't specify a taskpane ID,
                               and so it is different by default (but probably
                               should be explicit, come to think of it...)

                <SourceLocation resid="PG.Run.Url" /> 
                <Title resid="PG.RunCommand.Title" />
              </Action>
            </Control>

For the auto-open in particular, see https://dev.office.com/docs/add-ins/design/automatically-open-a-task-pane-with-a-document.

  • Sorry Michael, does it work in Excel Online? I cannot put 2 taskpanes of Script Lab side by side in Excel Online... – SoftTimur Jul 15 '17 at 22:23
  • You can't put them side by side, but you'll see that they are vertically tabbed. So you can in fact have two open, it's just that only one will be visible at a time. If you want more UI flexibility than that, I suggest you file an issue on https://officespdev.uservoice.com/ – Michael Zlatkovsky - Microsoft Jul 16 '17 at 02:13