【问题标题】:"This command is not available." error occurs when trying to execute PasteAndFormat function“此命令不可用。”尝试执行 PasteAndFormat 函数时发生错误
【发布时间】:2020-06-01 17:09:38
【问题描述】:

我发布了 VSTO 应用,我在其中复制了一个带有格式化文本的 Range。

在大多数用户的机器上,应用程序可以正常运行,而有些用户则出现错误“此命令不可用”。每当以下代码被执行时抛出。

  var sourceDocument = Globals.ThisAddIn.Application.ActiveDocument;
  sourceDocument.Range().Copy();
  Document documentOld = new Document();
  documentOld.Range().PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting); //here the error occurs
  Document documentNew = new Document();
  documentNew.Range().PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting);

你能给我推荐点什么吗?我应该检查用户机器上 Word 应用程序的任何设置吗?

非常感谢您的帮助!

提前谢谢你!

【问题讨论】:

    标签: c# range vsto ms-office word


    【解决方案1】:

    似乎有时 Word 中的 PasteAndFormat / Paste Special 在创建新文档时会被禁用。这可以在 Word 中手动复制,打开一个新文档,将某些内容复制到剪贴板并检查粘贴选项菜单:

    为了解决这个问题,我做的是正常粘贴,然后删除内容,然后使用PasteAndFormat

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      • 2014-09-07
      • 2021-04-23
      • 1970-01-01
      相关资源
      最近更新 更多