首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >自动开启侧装面板

自动开启侧装面板
EN

Stack Overflow用户
提问于 2019-06-02 10:06:53
回答 1查看 825关注 0票数 2

是否有可能自动打开处于开发模式的插件?

根据文档

指定自动打开的窗格只有在用户的设备上已安装外接程序时才会打开。如果用户在打开文档时没有安装外接程序,则自动打开功能将无法工作,该设置将被忽略。如果还需要在文档中分发外接程序,则需要将可见性属性设置为1;这只能使用OpenXML完成,本文稍后将提供一个示例。

特别是,我试图自动打开的文件是基于办公室发电机的文件,只需进行一次修改:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <we:webextension xmlns:we="http://schemas.microsoft.com/office/webextensions/webextension/2010/11" id="{acbc717b-5139-428a-9089-e9d6d7d8affc}">
  <we:reference id="acbc717b-5139-428a-9089-e9d6d7d8affc" version="1.0.0.0" store="developer" storeType="Registry"/>
  <we:alternateReferences/>

  <we:properties>
    <we:property name="Office.AutoShowTaskpaneWithDocument" value="true"/>
  </we:properties>

  <we:bindings/>
  <we:snapshot xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"/>
</we:webextension>

加入<we:property name="Office.AutoShowTaskpaneWithDocument" value="true"/>

并将manifest.xml修改如下:

代码语言:javascript
运行
复制
<Action xsi:type="ShowTaskpane">
  <TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>
  <SourceLocation resid="Taskpane.Url"/>
</Action>

问题:

预计会有一个自动打开的任务栏。

自动打开的任务窗格有一个错误,该错误声明为we can't find the task pane to open。另一方面,单击“带状”允许任务窗格按常规方式打开,并与破损的自动打开的任务窗格并排打开,如下图所示:

EN

回答 1

Stack Overflow用户

发布于 2019-06-07 04:39:37

微软的Word中有一种隐藏状态,即使在重启之后,这种状态也会持续存在。要再现错误,您非常需要一个新计算机

让我解释一下我是怎么让它在.一周。

首先从office-js生成器开始。

yo office,我为它选择了打字稿。

修改src/task窗格/taskpane.ts如下:

代码语言:javascript
运行
复制
export async function run() {
  return Word.run(async context => {
    /**
     * Insert your Word code here
     */

    // insert a paragraph at the end of the document.
    const paragraph = context.document.body.insertParagraph("Hello World", Word.InsertLocation.end);

    // change the paragraph color to blue.
    paragraph.font.color = "blue";

    // Add these two lines
    Office.context.document.settings.set("Office.AutoShowTaskpaneWithDocument", true);
    Office.context.document.settings.saveAsync();
    // Technically should wait, but doesn't matter.

    await context.sync();
  });

修改manifest.xml如下:将ButtonId1替换为Office.AutoShowTaskpaneWithDocument

代码语言:javascript
运行
复制
<Action xsi:type="ShowTaskpane">
  <TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>
  <SourceLocation resid="Taskpane.Url"/>
</Action>

按照正常情况启动项目。npm run start

单击“运行”按钮可触发自动打开文件的创建。

把文件保存在某个地方。

重新打开它来验证它是否有效。有趣的是,当我单击“显示”任务窗格按钮时,它创建了一个相同的任务窗格。这是个窃听器,但对我有用。毕竟是为了测试的目的。

要证明该文件的问题确实是隐藏状态:在新计算机npm run start上复制回购文件,复制该文件。

运行该文件,您将得到相同的问题,我在我的原始帖子。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56414047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档