2014-03-28 51 views
0

我知道如何獲取單詞文檔中的每個段落。但我正在尋找一種方法來循環訪問MS Word文檔中的每個單詞。如何遍歷word文檔中的每個單詞 - VBA宏

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 
+0

你試過[這](http://msgroups.net/microsoft.public.word.vba.general/looping-through-every-word/68673)? –

回答

3
For Each sentence In ActiveDocument.StoryRanges 
    For Each w In sentence.Words 
     Debug.Print w 
    Next 
Next 
+0

Objective-C中是否存在類似的東西? – jroyce

相關問題