Sub abc()
Dim App, WrdDoc, MyPath, MyFile, BM, Str
Mypath = "檔案實際路徑\*.doc" "請修改實際儲存路徑!
Set App = CreateObject("Word.Application") "用Set關鍵字建立Word應用成序物件!
MyFile = Dir(Mypath) " 獲得第一個WORD文件
do while MyFile "" " 遍歷Mypath下面的所有WORD文件
App.Visible = True
Set WrdDoc = App.Documents.Open(MyFile) "開啟這個Word檔案!
for each BM in WrdDoc.Bookmarks " 遍歷文件中的所有書籤
Str = BM.Range " 讀取書籤內容
next BM
WrdDoc.Close " 關閉檔案
MyFile = Dir " 下一個WORD文件
Loop
Set App = Nothing
End Sub
Sub abc()
Dim App, WrdDoc, MyPath, MyFile, BM, Str
Mypath = "檔案實際路徑\*.doc" "請修改實際儲存路徑!
Set App = CreateObject("Word.Application") "用Set關鍵字建立Word應用成序物件!
MyFile = Dir(Mypath) " 獲得第一個WORD文件
do while MyFile "" " 遍歷Mypath下面的所有WORD文件
App.Visible = True
Set WrdDoc = App.Documents.Open(MyFile) "開啟這個Word檔案!
for each BM in WrdDoc.Bookmarks " 遍歷文件中的所有書籤
Str = BM.Range " 讀取書籤內容
next BM
WrdDoc.Close " 關閉檔案
MyFile = Dir " 下一個WORD文件
Loop
Set App = Nothing
End Sub