首页 > 解决方案 > 即使没有打开任何文档,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}");

    }

标签: c#ms-wordvstoword-addins

解决方案


Documents.Count属性返回一个整数,表示集合中的文档数。每次启动 Word 时似乎都会创建一个新文档。


推荐阅读