Sub GetWordDocumentData()
'Note: this code requires a reference to the Word object model, added via Tools|References
Application.ScreenUpdating = False
Dim StrFolder As String, StrFile As String, WkSht As Worksheet
StrFolder = GetFolder
If StrFolder = "" Then Exit Sub
Dim wdApp As New Word.Application, wdDoc As Word.Document
wdApp.DisplayAlerts = wdAlertsNone
StrFile = Dir(StrFolder & "\*.doc")
While StrFile <> ""
On Error Resume Next
Set WkSht = Sheets.Add
MsgBox Split(StrFile, ".doc")(0)
WkSht.Name = Split(StrFile, ".doc")(0)
Set wdDoc = wdApp.Documents.Open(Filename:=StrFolder & "\" & StrFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
.Range.Copy
.Close SaveChanges:=False
End With
WkSht.PasteSpecial Format:="Microsoft Word 8.0 Document Object"
StrFile = Dir()
Wend
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function