Sub Main()
Dim aryDocArray
Dim strWdDoc As String
Dim strWdSaveAs As String
Dim strAccTable As String
Dim strPath As String
'Get list of .doc files, two files only in this directory
'one table per file
strPath = "C:\testdoc\"
aryDocArray = Split(GetFileList(strPath, "*.doc"), ",")
'Loop through .doc array
For i = 0 To UBound(aryDocArray)
'Names for everything
strWdDoc = strPath & aryDocArray(i)
strWdSaveAs = strPath & Left(aryDocArray(i), Len(aryDocArray(i)) - 4) & ".htm"
strAccTable = Left(aryDocArray(i), Len(aryDocArray(i)) - 4)
'Word stuff
Call OpenWordDocs(strWdDoc, strWdSaveAs)
'Access tables
DoCmd.TransferText acImportHTML, "", strAccTable, strWdSaveAs, False, ""
Next i
End Sub
Function OpenWordDocs(ByVal strWrdDocName As String, strSaveAs As String)
Dim objWord As Word.Document
'Modified (stolen) from Tek-Tips post
'Open word file
Set objWord = GetObject(strWrdDocName, "Word.Document")
objWord.Application.Visible = True
objWord.Application.DisplayAlerts = wdAlertsNone
'Save as .htm
With objWord
.Application.ActiveDocument.SaveAs FileName:= _
strSaveAs, FileFormat:=wdFormatHTML, _
AddToRecentFiles:=False
.Application.Quit wdDoNotSaveChanges
End With
End Function
Function GetFileList(strDirPath As String, _
Optional strFileSpec As String = "*.*", _
Optional strDelim As String = ",", _
Optional vFileType = vbNormal) As String
'Modified from code library?
Dim strFileList As String ' Used to collect the file list.
Dim strFileNames As String ' The full path and criteria to search for.
Dim strTemp As String ' Temporarily holds the matching file name.
' Make sure that strDirPath ends in a "\" character.
If Right$(strDirPath, 1) <> "\" Then
strDirPath = strDirPath & "\"
End If
' This will be our file search criteria.
strFileNames = strDirPath & strFileSpec
' Create a list of matching files delimited by the
' strDelim character.
strTemp = Dir$(strFileNames, vFileType)
Do While Len(strTemp) <> 0
strFileList = strFileList & strTemp & strDelim
strTemp = Dir$()
Loop
If strFileList <> "" Then
strFileList = Left(strFileList, Len(strFileList) - 1)
End If
GetFileList = strFileList
End Function