我正在尝试阅读word文档并在那里循环显示段落数量并获取该段落中的文本。
由于某种原因,当它应该返回'3'时,计数返回'7'。
这是我写的代码:
Dim missing As Object = System.Type.Missing
Dim application As New DOCApplication.Application()
Dim document As DOCApplication.Document = application.Documents.Open(OpenFileDialog.FileName, missing, missing, missing,
missing, missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing)
Dim data As New List(Of String)()
For index = 0 To document.Paragraphs.Count
Dim temp As String = document.Paragraphs(index + 1).Range.Text.Trim()
If temp <> String.Empty Then
data.Add(temp)
End If
Next
我的代码有问题吗?