论坛有个例子,可以读取整篇WORD文档的内容,不知道能否修改为按需要读取其中部分段落,比如
整篇WORD有10~20段内容,按需读取其中第7段,第8~最后前一段,最后一段,这样三部分内容。
Dim app As New MSWord.Application
try
Dim fileName = "d:\test.doc"
app.Documents.Open(fileName)
Dim count = app.Documents(fileName).Characters.Count
Dim rng As MSWord.Range = app.Documents(fileName).Range(Start:=0, End:=count)
msgbox(rng.Text)
rng.Select() '全选
rng.Copy() '拷贝
catch ex As exception
msgbox(ex.message)
finally
app.Quit
End try