【问题标题】:How to get the paragraph Number from Word Document in VSTO如何从 VSTO 中的 Word 文档中获取段落编号
【发布时间】:2017-12-05 21:04:09
【问题描述】:

假设我们在文档中有一段如下:

  1. 橙色
  2. 苹果
  3. 芒果

我需要检索段落中每个实体的编号列表。对于 Orange-1、Apple-2 和 Mango-3 我已经使用下面的代码来查找文档中的段落列表。 Word.Paragraphs para = ActiveDocument.Paragraphs;

我需要从 para 对象中找出每个实体的列表编号。

【问题讨论】:

    标签: c# asp.net ms-word vsto


    【解决方案1】:

    我不是 100% 我理解您的问题,但您似乎在 3 个段落中使用了编号列表样式,并且您想获取编号列表样式的值? (1、2 和 3)

    VBA/VSTO/etc 中的一个词 Paragraph 有一个 Range 对象 在 Range 对象上,您将找到 ListFormat 对象,它为您提供所需的信息。

    因此,如果您在第一段中有: 1. 橙色 那么你可以使用:

    ActiveDocument.Paragraphs[1].Range.ListFormat.ListString
    

    这将为您提供“1”。 还有

    ActiveDocument.Paragraphs[1].Range.ListFormat.ListValue
    

    这会给你1

    祝你好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 2022-01-04
      相关资源
      最近更新 更多