两个开放的任务窗口并排

时间:2017-07-04 03:38:37

标签: ms-office office-js office-addins office-app

我正在创建一个Office加载项,它有两个功能区按钮。每个按钮都链接到不同的TaskpaneId,点击每个按钮会打开一个不同的任务窗格:

<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>

似乎我已经看到了一些Office加载项,其中两个任务窗格可以同时并排显示(我忘记了加法项的确切位置)。我不时需要这个,有谁知道如何实现这个目标?

1 个答案:

答案 0 :(得分:0)

Script Lab就是这样一个加载项。您需要做的就是创建两个不同的按钮,其ShowTaskpane动作不同的ID

Script Lab的prod清单示例: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>

特别是对于自动打开,请参阅https://dev.office.com/docs/add-ins/design/automatically-open-a-task-pane-with-a-document