下面是 C# 代码示例,展示如何使用 Microsoft.Office.Interop.Word 库操作 Word 文档,取消第二行的列表格式:

using Microsoft.Office.Interop.Word;

// 创建Word应用程序对象
Application wordApp = new Application();

// 打开文档
Document doc = wordApp.Documents.Open('C:\example.docx');

// 取消第二行的列表ListGalleries
ListGallery listGallery = doc.ListGalleries[WdListGalleryType.wdNumberGallery];
ListLevel listLevel = listGallery.ListLevels[2];
listLevel.NumberFormat = '';

// 保存并关闭文档
 doc.Save();
doc.Close();

// 退出Word应用程序
wordApp.Quit();

这段代码首先创建了一个 Word 应用程序对象,然后打开了一个文档。接着,它获取了文档中的 ListGalleries 对象,并取消了第二行的列表。最后,它保存并关闭了文档,并退出了 Word 应用程序。

C# 操作 Word 取消第二行列表 - 代码示例

原文地址: https://www.cveoy.top/t/topic/oX62 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录