close

參考來源:http://forum.twbts.com/thread-732-1-1.html

Dim mystr
Set myrange = ActiveDocument.Content

With myrange.Find   '尋找整份文件

   Do While (.Execute("關鍵字1") Or .Execute("關鍵字2"))   '設定要找的關鍵字
        mystr = "P" & .Parent.Information(wdActiveEndPageNumber)  '記錄所在的頁
        打包 = 打包 & mystr & "Λ" & myrange1.Paragraphs(1) '顯示各個段落,開頭顯示在原來的文件中的頁碼
        myrange1.EndOf wdParagraph '段落中找到任一個關鍵字後,直接到段落最後,再讀取下一段落,避免重複
   Loop 


End With

If IsEmpty(打包) Then MsgBox "找不到!": Exit Sub   '若整份文件均找不到則顯示出訊息框
Documents.Add: Selection = 打包

arrow
arrow
    全站熱搜

    就是要紅 發表在 痞客邦 留言(0) 人氣()