c# - 即使没有打开任何文档,Globals.ThisAddIn.Application.Documents.Count 也会返回 1
问题描述
即使没有打开任何文档,Globals.ThisAddIn.Application.Documents.Count 也会返回 1。下面代码在创建新文档之前返回 1:
private void Ribbon_Load(object sender, RibbonUIEventArgs e)
{
MessageBox.Show($"Document count {Globals.ThisAddIn.Application.Documents.Count}");
}
解决方案
Documents.Count属性返回一个整数,表示集合中的文档数。每次启动 Word 时似乎都会创建一个新文档。
推荐阅读
- python - 在 QPlainTextEdit 中突出显示部分文本
- html - Angular 没有第二次设置动态 HTML embed src 属性
- swift - 在 MacOS 的后台检测睡眠日期
- swift - 我可以将 Bool 作为环境对象传递给 SwiftUI 中的子视图吗?
- express - 如何在 Express JS 服务器日志中查看堆栈跟踪?
- java - bean定义未加载到spring上下文中
- java - 在 EnumSorts 上使用 mkEq 时出现 Z3 不兼容的排序错误
- javascript - 如何在 React 中使用自定义字体图标
- java - 垃圾收集加载画面
- javascript - 如何在数据表中自动修复下一页