循环遍历 word 文档中的每个单词 [英] Loop through each word in a word document
本文介绍了循环遍历 word 文档中的每个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何获取 Word 文档中的每个段落.但我正在寻找一种方法来遍历 MS Word 文档中的每个单词.
I know how to get every paragraph in a word document. But I am looking for a way to loop through each word in a MS Word document.
Sub Sample()
Dim apara As Paragraph
Dim lineText As String
For Each apara In ActiveDocument.Paragraphs
lineText = apara.Range
'Now print the paragraph
Debug.Print lineText
Next apara
End Sub
推荐答案
For Each sentence In ActiveDocument.StoryRanges
For Each w In sentence.Words
Debug.Print w
Next
Next
这篇关于循环遍历 word 文档中的每个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文