“此命令不可用."尝试执行 PasteAndFormat 函数时发生错误 [英] "This command is not available." error occurs when trying to execute PasteAndFormat function

查看:39
本文介绍了“此命令不可用."尝试执行 PasteAndFormat 函数时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发布了 VSTO 应用程序,在其中复制了一个带有格式化文本的范围.

I published the VSTO app, where I copy a Range with a formatted text.

在大多数用户计算机上,应用程序正常运行,而有些用户则出现错误此命令不可用".每当以下代码被排除时抛出.

On most users machines the application works properly while some users have the error "This command is not available." thrown whenever the following piece of code is being excetuded.

  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 应用程序的任何设置吗?

Could you recommend me something? Should I check any settings of the Word App on the User's machine?

非常感谢您的帮助!

先谢谢你!

推荐答案

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

Seems like sometimes the PasteAndFormat / Paste Special in Word is disabled upon creating a new Document. This can be reproduced manually in Word opening a new document, copying something to the clipboard and checking the paste options menu:

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

What I do in order to counteract this, is to do a normal paste, then delete the content and then use the PasteAndFormat.

这篇关于“此命令不可用."尝试执行 PasteAndFormat 函数时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆