'Open Spreadsheet
Set db = OpenDatabase(strSourceFile, False, True, "Excel 8.0;HDR=Yes;")
' list worksheet names
Debug.Print "Number of sheets: "; db.TableDefs.Count
Rem Start cycle through the spreadsheet.
For i = 0 To db.TableDefs.Count - 1
Debug.Print db.TableDefs(i).Name
strSheetName = db.TableDefs(i).Name
Rem Debug.Print strSheetName Like "[a-z]$"
If strSheetName Like "[A-Z]$" Then
strSQL = "Select * FROM " & "[" & strSheetName & "]"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.BOF And rs.EOF Then
Rem error condition
Debug.Print "No Records for this sheet"
Debug.Print "Sheet: "; db.TableDefs(i).Name
Else
rs.MoveLast
rs.MoveFirst
Rem On Error GoTo ReportError
Do Until rs.EOF
bolErrorCheck = False
bolErrorSkip = False
If IsNull(rs!author) Or rs!author = "" Then bolErrorCheck = True
If IsNull(rs!TITLE) Or rs!TITLE = "" Then bolErrorCheck = True
If Not IsDate(rs!Date) Then bolErrorCheck = True
Rem -------------------------------------------------------------------------------
If IsNumeric(rs!Page) Then
If IsNull(rs!Page) Or rs!Page = 0 Then lonPageNUM = 9999: bolErrorCheck = True Else lonPageNUM = CLng(rs!Page)
Else
lonPageNUM = 9999
End If
If IsNull(rs!Type) Or Trim(rs!Type) = "" Then strStoryType = "???": bolErrorCheck = True Else strStoryType = rs!Type
Rem----------------------------------------------------------------------------------
If bolErrorCheck = True Then Debug.Print "Author: "; rs!author, "Title: "; rs!TITLE, "Page: "; lonPageNUM, "Type: "; rs!Type, "Date: "; IIf(IsDate(rs!Date), rs!Date, "Date Error")
If IsNull(rs!author) Or Trim(rs!author) = "" Then bolErrorSkip = True
If IsNull(rs!TITLE) Or Trim(rs!TITLE) = "" Then bolErrorSkip = True
imrs.AddNew
imrs!author = rs!author
imrs!TITLE = rs!TITLE
imrs!Date = IIf(IsDate(rs!Date), rs!Date, #1/1/1800#)
imrs!Page = lonPageNUM
imrs!Type = strStoryType
imrs.Update
bolErrorCheck = False
bolErrorSkip = False
rs.MoveNext
Loop
End If
End If
Next i
Rem End Spreadsheet Cycle