2016-11-23 67 views
1

我正在使用Microsoft Word 2010.使用特定字符串刪除每一行

我有一個跨越數千頁的文檔。我需要編寫一個宏,刪除以字符串mystring開頭的每個段落。我怎麼寫這個?

編輯:我已經想通了如何寫一個宏,以及如何刪除段落,一旦我的光標在段落的開頭。我需要找到一種方法來做「查找」搜索

回答

3
Dim d As Document 
Dim p As Paragraph 

Set d = ActiveDocument 

For Each p In d.Paragraphs 
    If Left(p.Range, Len("Asdfsadfsdsd")) = "Asdfsadfsdsd" Then 
     p.Range.Delete 
    End If 
Next p