Open directly a web page from a button in Ribbon in a browser outside Excel?

泄露秘密 提交于 2021-02-08 09:36:26

问题


We have several Excel add-ins in AppSource. At the moment, we have a button in Ribbon for Documentation, clicking on the button opens the documentation webpage in a taskpane in Excel.

We feel that as the taskpane is small, people are unlikely to read documentation over there. So a better way would be to open the documentation webpage in a browser outside Excel.

We notice that in Script Lab, clicking on the Reference Docs opens a small window which contains open link in new window. Then, we need to click on that link to finally open that in a browser:

https://user-images.githubusercontent.com/774409/81099107-ab068e80-8f0a-11ea-9633-eba5c1e42f90.png

So do we have to have this intermediate window? Cannot we open directly a web page from a button in Ribbon in a browser outside Excel?

PS: I don't want to use Dialog API to show documentation, because it seems that when the Dialog window is open, we cannot use Excel at the same time?


回答1:


In manifest, you could make it UI less, and specifies the source code file for operations that an add-in exposes through add-in commands that execute a JavaScript function instead of displaying UI,

<DesktopFormFactor>
  <FunctionFile resid="residDesktopFuncUrl" />
  <ExtensionPoint xsi:type="PrimaryCommandSurface">
    <!-- information about this extension point -->
  </ExtensionPoint>        
</DesktopFormFactor>

and in the FunctionFile you could add a function, which can call Office.context.ui.openBrowserWindow(url) to launch the URL in the default browser outside of excel

Office.context.ui.openBrowserWindow("https://github.com");

The document can be found at here, which describes how to implement the function defined by FunctionName in the manifest.



来源:https://stackoverflow.com/questions/61736702/open-directly-a-web-page-from-a-button-in-ribbon-in-a-browser-outside-excel

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