Let the button open a new window

我怕爱的太早我们不能终老 提交于 2019-12-20 05:41:11

问题


I want to add a button under the tab of my add-in, and clicking on the button should open a URL in a new window or Dialog box. I tried the follows:

<Group id="Contoso.Tab1.Group2">
    <Label resid="Contoso.Tab1.GroupLabel" />
    <Icon>
        <bt:Image size="16" resid="Contoso.TaskpaneButton3.Icon" />
        <bt:Image size="32" resid="Contoso.TaskpaneButton3.Icon" />
        <bt:Image size="80" resid="Contoso.TaskpaneButton3.Icon" />
    </Icon>
    <Control xsi:type="Button" id="Contoso.TaskpaneButton3">
        <Label resid="Contoso.TaskpaneButton3.Label" />
        <Supertip>
            <Title resid="Contoso.TaskpaneButton3.Label" />
            <Description resid="Contoso.TaskpaneButton3.Tooltip" />
        </Supertip>
        <Icon>
            <bt:Image size="16" resid="Contoso.TaskpaneButton3.Icon" />
            <bt:Image size="32" resid="Contoso.TaskpaneButton3.Icon" />
            <bt:Image size="80" resid="Contoso.TaskpaneButton3.Icon" />
        </Icon>
        <Action xsi:type="ShowTaskpane">
            <TaskpaneId>Button3</TaskpaneId>
            <SourceLocation resid="Contoso.Taskpane3.Url" />
        </Action>
    </Control>
</Group>

... ...

   <bt:Url id="Contoso.Taskpane3.Url" DefaultValue="https://www.stackoverflow.com/" />

The problem is that it still tries to open that link in a task pane, rather than a new window or Dialog box. Does anyone know how to amend the manifest to achieve this?


回答1:


after googling about office dev , I found that you can change the action tag to something like

<!-- This is what happens when the command is triggered (E.g. click on the Button). Supported actions are ExecuteFunction or ShowTaskpane. -->
              <Action xsi:type="ExecuteFunction">
                <FunctionName>doSomethingAndShowDialog</FunctionName>
              </Action>

check the following link it might be helpful

https://github.com/OfficeDev/Office-Add-in-Dialog-API-Simple-Example



来源:https://stackoverflow.com/questions/45388791/let-the-button-open-a-new-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!