P
Paul
So I decided to post it here. I have read as many message boards as I
could find about the error I continue to receive. "Compile Error: Only
comments may appear after End Sub, End Function, or End Property" I
have seen posts referring to either APIs or Function Declarations. I
do not have either of these in my code. I also saw a post that
recommended keping the size of the module below 64k. My code was less
than 50k, but to be on the safe side I split it up to two modules and
adjusted the code accordingly. I still get the error. Excel is
highlighting the first line of the last Sub in the module. I will post
all of module1 and two of the subs from module2. I can post the last
function if it is deemed necessary, I just didn't want this post to be
longer than it had to be. Cheers!
'Module1 Code:
Public Type activityType
exist As Boolean
End Type
Public Type levelType
exist As Boolean
End Type
Public Type strandType
exist As Boolean
activity(1 To 10) As activityType
End Type
Public Type stationType
exist As Boolean
level(1 To 4) As levelType
End Type
Public Type dayType
exist As Boolean
strand(1 To 4) As strandType
End Type
Public Type readingLessonType
exist As Boolean
station(1 To 10) As stationType
days(1 To 5) As dayType
End Type
Public Type lessonType
exist As Boolean
End Type
Public Type chapterType
exist As Boolean
lesson(50) As lessonType
End Type
Public Type unitType
exist As Boolean
chapter(50) As chapterType
End Type
Public Type readingUnitType
exist As Boolean
readingLesson(10) As readingLessonType
End Type
Public Function OpenFile() As Variant
Dim filex As Variant
filex = Application.GetOpenFilename(Title:="Select Files",
MultiSelect:=True)
OpenFile = filex
End Function
Public Function StripFileName(ByRef filename As Variant, ByVal cell As
Integer) As String
Dim myArray As Variant
myArray = Split(filename(cell), "\") 'Remove the tree
structure from the filename
filename(cell) = myArray(UBound(myArray)) 'Store JUST the
file name
myArray = Split(myArray(UBound(myArray)), "_") 'Remove _'s
myArray = Split(myArray(UBound(myArray)), ".") 'Remove the .'s
leaving just the file name and xls
StripFileName = myArray(0) 'Return just the
file name
End Function
Public Function OrderFileList(ByRef fileList As Variant) As Variant
Dim strTempList(13) As String
Dim orgFileList As Variant
Dim strTemp As String
Dim i As Integer
Dim isReading As Boolean
orgFileList = fileList
isReading = IsItReading()
For i = 1 To UBound(fileList)
strTemp = StripFileName(fileList, i)
strTempList(i - 1) = strTemp
Next
i = FindFileName(strTempList, "eplanner")
orgFileList(1) = fileList(i)
i = FindFileName(strTempList, "book")
orgFileList(2) = fileList(i)
i = FindFileName(strTempList, "unit")
orgFileList(3) = fileList(i)
If isReading Then
i = FindFileName(strTempList, "lesson")
orgFileList(4) = fileList(i)
i = FindFileName(strTempList, "day")
orgFileList(5) = fileList(i)
i = FindFileName(strTempList, "strand")
orgFileList(6) = fileList(i)
i = FindFileName(strTempList, "activity")
orgFileList(7) = fileList(i)
i = FindFileName(strTempList, "station")
orgFileList(8) = fileList(i)
i = FindFileName(strTempList, "level")
orgFileList(9) = fileList(i)
i = FindFileName(strTempList, "resbook")
orgFileList(10) = fileList(i)
i = FindFileName(strTempList, "resunit")
orgFileList(11) = fileList(i)
i = FindFileName(strTempList, "reslesson")
orgFileList(12) = fileList(i)
i = FindFileName(strTempList, "resactivity")
orgFileList(13) = fileList(i)
i = FindFileName(strTempList, "resstationactivity")
orgFileList(14) = fileList(i)
Else
i = FindFileName(strTempList, "chapter")
orgFileList(4) = fileList(i)
i = FindFileName(strTempList, "lesson")
orgFileList(5) = fileList(i)
i = FindFileName(strTempList, "resbook")
orgFileList(6) = fileList(i)
i = FindFileName(strTempList, "resunit")
orgFileList(7) = fileList(i)
i = FindFileName(strTempList, "reschapter")
orgFileList(8) = fileList(i)
i = FindFileName(strTempList, "reslesson")
orgFileList(9) = fileList(i)
End If
OrderFileList = orgFileList
End Function
Public Function CheckForErrors(ByVal strFileType As String, ByVal
strFileName As String)
Dim intFlag As Integer
Dim isReading As Boolean
Module2.SwapToFile (strFileName)
LastRow = Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
isReading = IsItReading()
'The junk variable is required because a sub can't be used if
passing multiple parameters
'and a function is required to be = to something
junk = CheckData(LastRow, strFileName, "ISBN") 'Always
check the ISBN column
Select Case strFileType 'Determine which
file we are checking.
'Each case has the
"checkable" columns underneath it
Case "lesson"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName,
"CHAPTER_NUMBER")
junk = CheckData(LastRow, strFileName, "STARS_GUID")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "PACING")
Case "reslesson"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName,
"CHAPTER_NUMBER")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "resunit"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "unit"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "PACING")
Case "book"
junk = CheckData(LastRow, strFileName, "GRADE_ID")
junk = CheckData(LastRow, strFileName, "LOCATION_ID")
Case "chapter"
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName, "CHAPTER_NUMBER")
junk = CheckData(LastRow, strFileName, "PACING")
Case "eplanner"
junk = CheckData(LastRow, strFileName, "SUBJECT")
junk = CheckData(LastRow, strFileName, "GRADE_ID")
junk = CheckData(LastRow, strFileName, "LOCATION_ID")
Case "resbook"
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "reschapter"
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName, "CHAPTER_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "strand"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
junk = CheckData(LastRow, strFileName, "STRAND_NUMBER")
Case "station"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "STATION_NUMBER")
Case "level"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "STATION_NUMBER")
junk = CheckData(LastRow, strFileName, "LEVEL_NUMBER")
Case "day"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
Case "activity"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
junk = CheckData(LastRow, strFileName, "STRAND_NUMBER")
junk = CheckData(LastRow, strFileName, "ACTIVITY_NUMBER")
junk = CheckData(LastRow, strFileName, "STARS_GUID")
Case "resactivity"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
junk = CheckData(LastRow, strFileName, "STRAND_NUMBER")
junk = CheckData(LastRow, strFileName, "ACTIVITY_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "resstationactivity"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "STATION_NUMBER")
junk = CheckData(LastRow, strFileName, "LEVEL_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case Else
MsgBox ("Unrecognized file type. The error checker has not
been " + vbCrLf + _
"adapted to this file type: " + vbCrLf + vbCrLf + vbTab +
vbTab + filetype)
End Select
Module2.SwapToFile (strFileName)
ActiveWorkbook.Close False
End Function
Private Function FindFileName(ByVal fileList As Variant, ByVal
strFileType As String) As Integer
Dim i As Integer
For i = 0 To UBound(fileList)
If fileList(i) = strFileType Then
FindFileName = i + 1
Exit For
End If
Next
End Function
Private Function CheckData(ByVal intBottomOfInfo As Integer, ByVal
strFile As String, ByVal strCol As String)
'Checks the imported column (strCol)to make sure that it conforms to
the correct format of the respective column
'including no inappropriate spaces
Dim test, test2, test3, flag As Boolean
Dim strTemp, strTest, strTest2, strTest3 As String
Select Case strCol
Case "ISBN" 'ISBN column
strTest = "##########"
strTest2 = "#############"
strTest3 = "#########[0-Z]"
Case "SYLLABUS_ITEM_ID", "CONTENT_ID", "BOOK_ID"
'Syllabus_Item_ID, Content_ID, Book_ID
strTest =
"[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]"
+ _
"[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]"
strTest2 = strTest
strTest3 = strTest
Case "STARS_GUID" 'Stars_GUID
strTest =
"[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]-[0-Z][0-Z][0-Z][0-Z]-[0-Z][0-Z][0-Z][0-Z]-"
+ _
"[0-Z][0-Z][0-Z][0-Z]-[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]"
strTest2 = strTest
strTest3 = strTest
Case "PACING" 'Pacing
strTest = "#"
strTest2 = "#.#"
strTest3 = "##.#"
Case "RES_TYPE_ID", "RES_CAT_ID" 'RESOURCE IDs
junk = CheckRES_ID(intBottomOfInfo, strCol, strFile)
Exit Function
Case Else 'Any plain
numeric column
strTest = "#"
strTest2 = "##"
strTest3 = "###"
End Select
Module2.SwapToFile (strFile)
intColNum = FindWhichColumn(strCol)
For intRowNum = 2 To intBottomOfInfo
flag = True
strTemp = Cells(intRowNum, intColNum).Value2
test = strTemp Like strTest
test2 = strTemp Like strTest2
test3 = strTemp Like strTest3
If Cells(intRowNum, intColNum) = "" Then
strTemp = strFile & ": There is no number in column: " &
strCol & " row: " & intRowNum
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
flag = False
ElseIf (Not test) And (Not test2) And (Not test3) Then
strTemp = strFile & ": Improper number format in column: "
& strCol & " row: " & intRowNum
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
flag = False
End If
If strCol = "ISBN" And flag Then
If Cells(intRowNum, intColNum).Value2 <> Cells(2, 1).Value2
Then
strTemp = strFile & ": There is a differing " & strCol
& " in row: " & intRowNum
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
End If
End If
Next
Module2.SwapToErrorChecker
End Function
Private Function CheckRES_ID(ByVal intBottomOfInfo As Integer, ByVal
strCol As String, ByVal strFile As String)
Dim ResList(50), strTemp As String 'Chose the array to be 50
elements because that would cover both RES lists
Dim intRow, intCol, i, intURICol As Integer 'with some room
for growth.
intRow = 1
Module2.SwapToErrorChecker
Sheets(strCol).Activate
Cells(intRow, 1).Select
While Cells(intRow, 1).Value2 <> ""
ResList(intRow) = Cells(intRow, 1).Value2
intRow = intRow + 1
Wend
ResList(intRow + 1) = "End of List" 'Insert manual EOF
Module2.SwapToFile (strFile)
intRow = 2
intCol = FindWhichColumn(strCol)
intURICol = FindWhichColumn("URI")
For intRow = 2 To intBottomOfInfo
i = 1
Do While ResList(i) <> "End of List"
If Cells(intRow, intCol).Value2 = ResList(i) Then
If ResList(i) = "D661E0B7264D1B55E034080020A7D594" Or
ResList(i) = "D661E0B7264E1B55E034080020A7D594" Then
If Cells(intRow, intURICol).Value2 = "" Then
strTemp = strFile & ": Resource listed without
corresponding URI on row: " & intRow
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 1)
Module2.SwapToFile (strFile)
End If
End If
Exit Do
Else
i = i + 1
End If
If ResList(i) = "End of List" Then
strTemp = strFile & ": Invalid " & strCol & " in row: "
& intRow
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
End If
Loop
intRow = intRow + 1
Next
Module2.SwapToErrorChecker
End Function
Private Function FindWhichColumn(ByVal strColName As String) As Integer
Dim intColNum As Integer
intColNum = 1
While Cells(1, intColNum).Value2 <> ""
If Cells(1, intColNum).Value2 = strColName Then
FindWhichColumn = intColNum
Exit Function
End If
intColNum = intColNum + 1
Wend
FindWhichColumn = 255
End Function
Private Function InsertNextMessage(ByVal strError As String, ByVal
choice As Integer)
'Used to insert an error message in the proper location, "Possible
Errors" or "Warnings" based on "choice"
'choice = 0 <--- Possible Error
'choice = 1 <--- Warning
Dim strSearch As String
Select Case choice
Case 0
strSearch = "Possible Errors"
Case 1
strSearch = "Warnings"
End Select
CurrCell = Cells.Find(What:=strSearch, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
If Cells(Selection.Row + 1, 1).Value2 <> "No errors found." Then
'test to see if entering first error/warning
If Cells(Selection.Row + 2, 1).Value2 <> "" Then 'test
to see if entering second error/warning
Selection.End(xlDown).Offset(1, 0).Select
Rows(Selection.Row).Select
Selection.Insert Shift:=xlDown
Cells(Selection.Row, 1).Value2 = strError
Else
Rows(Selection.Row + 2).Select
Selection.Insert Shift:=xlDown
Cells(Selection.Row, 1).Value2 = strError
End If
Else
Cells(Selection.Row + 1, 1).Value2 = strError
Rows(Selection.Row + 2).Select
Selection.Insert Shift:=xlDown
End If
End Function
Private Function IsItReading() As Boolean
Dim isReading As Boolean
intFlag = FindWhichColumn("THEME_NUMBER") 'Test to determine if
it is a reading group if 'THEME_NUMBER' doesn't exist
If intFlag <> 32767 Then 'intFlag is set to
32767
If Cells(2, intFlag).Value2 = "" Then
intFlag = 32767
isReading = False
Else
isReading = True
End If
Else
isReading = False
End If
IsItReading = isReading
End Function
'Module2 Code:
Public Sub SwapToErrorChecker()
Windows("ErrorChecker.xls").Activate
Sheets("Errors").Activate
End Sub
Public Sub SwapToFile(ByVal strFile As String)
Windows(strFile).Activate
Sheets(1).Activate
End Sub
could find about the error I continue to receive. "Compile Error: Only
comments may appear after End Sub, End Function, or End Property" I
have seen posts referring to either APIs or Function Declarations. I
do not have either of these in my code. I also saw a post that
recommended keping the size of the module below 64k. My code was less
than 50k, but to be on the safe side I split it up to two modules and
adjusted the code accordingly. I still get the error. Excel is
highlighting the first line of the last Sub in the module. I will post
all of module1 and two of the subs from module2. I can post the last
function if it is deemed necessary, I just didn't want this post to be
longer than it had to be. Cheers!
'Module1 Code:
Public Type activityType
exist As Boolean
End Type
Public Type levelType
exist As Boolean
End Type
Public Type strandType
exist As Boolean
activity(1 To 10) As activityType
End Type
Public Type stationType
exist As Boolean
level(1 To 4) As levelType
End Type
Public Type dayType
exist As Boolean
strand(1 To 4) As strandType
End Type
Public Type readingLessonType
exist As Boolean
station(1 To 10) As stationType
days(1 To 5) As dayType
End Type
Public Type lessonType
exist As Boolean
End Type
Public Type chapterType
exist As Boolean
lesson(50) As lessonType
End Type
Public Type unitType
exist As Boolean
chapter(50) As chapterType
End Type
Public Type readingUnitType
exist As Boolean
readingLesson(10) As readingLessonType
End Type
Public Function OpenFile() As Variant
Dim filex As Variant
filex = Application.GetOpenFilename(Title:="Select Files",
MultiSelect:=True)
OpenFile = filex
End Function
Public Function StripFileName(ByRef filename As Variant, ByVal cell As
Integer) As String
Dim myArray As Variant
myArray = Split(filename(cell), "\") 'Remove the tree
structure from the filename
filename(cell) = myArray(UBound(myArray)) 'Store JUST the
file name
myArray = Split(myArray(UBound(myArray)), "_") 'Remove _'s
myArray = Split(myArray(UBound(myArray)), ".") 'Remove the .'s
leaving just the file name and xls
StripFileName = myArray(0) 'Return just the
file name
End Function
Public Function OrderFileList(ByRef fileList As Variant) As Variant
Dim strTempList(13) As String
Dim orgFileList As Variant
Dim strTemp As String
Dim i As Integer
Dim isReading As Boolean
orgFileList = fileList
isReading = IsItReading()
For i = 1 To UBound(fileList)
strTemp = StripFileName(fileList, i)
strTempList(i - 1) = strTemp
Next
i = FindFileName(strTempList, "eplanner")
orgFileList(1) = fileList(i)
i = FindFileName(strTempList, "book")
orgFileList(2) = fileList(i)
i = FindFileName(strTempList, "unit")
orgFileList(3) = fileList(i)
If isReading Then
i = FindFileName(strTempList, "lesson")
orgFileList(4) = fileList(i)
i = FindFileName(strTempList, "day")
orgFileList(5) = fileList(i)
i = FindFileName(strTempList, "strand")
orgFileList(6) = fileList(i)
i = FindFileName(strTempList, "activity")
orgFileList(7) = fileList(i)
i = FindFileName(strTempList, "station")
orgFileList(8) = fileList(i)
i = FindFileName(strTempList, "level")
orgFileList(9) = fileList(i)
i = FindFileName(strTempList, "resbook")
orgFileList(10) = fileList(i)
i = FindFileName(strTempList, "resunit")
orgFileList(11) = fileList(i)
i = FindFileName(strTempList, "reslesson")
orgFileList(12) = fileList(i)
i = FindFileName(strTempList, "resactivity")
orgFileList(13) = fileList(i)
i = FindFileName(strTempList, "resstationactivity")
orgFileList(14) = fileList(i)
Else
i = FindFileName(strTempList, "chapter")
orgFileList(4) = fileList(i)
i = FindFileName(strTempList, "lesson")
orgFileList(5) = fileList(i)
i = FindFileName(strTempList, "resbook")
orgFileList(6) = fileList(i)
i = FindFileName(strTempList, "resunit")
orgFileList(7) = fileList(i)
i = FindFileName(strTempList, "reschapter")
orgFileList(8) = fileList(i)
i = FindFileName(strTempList, "reslesson")
orgFileList(9) = fileList(i)
End If
OrderFileList = orgFileList
End Function
Public Function CheckForErrors(ByVal strFileType As String, ByVal
strFileName As String)
Dim intFlag As Integer
Dim isReading As Boolean
Module2.SwapToFile (strFileName)
LastRow = Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
isReading = IsItReading()
'The junk variable is required because a sub can't be used if
passing multiple parameters
'and a function is required to be = to something
junk = CheckData(LastRow, strFileName, "ISBN") 'Always
check the ISBN column
Select Case strFileType 'Determine which
file we are checking.
'Each case has the
"checkable" columns underneath it
Case "lesson"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName,
"CHAPTER_NUMBER")
junk = CheckData(LastRow, strFileName, "STARS_GUID")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "PACING")
Case "reslesson"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName,
"CHAPTER_NUMBER")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "resunit"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "unit"
If isReading Then
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
Else
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
End If
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "PACING")
Case "book"
junk = CheckData(LastRow, strFileName, "GRADE_ID")
junk = CheckData(LastRow, strFileName, "LOCATION_ID")
Case "chapter"
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName, "CHAPTER_NUMBER")
junk = CheckData(LastRow, strFileName, "PACING")
Case "eplanner"
junk = CheckData(LastRow, strFileName, "SUBJECT")
junk = CheckData(LastRow, strFileName, "GRADE_ID")
junk = CheckData(LastRow, strFileName, "LOCATION_ID")
Case "resbook"
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "reschapter"
junk = CheckHierarchy(strFileType, strFileName, isReading,
LastRow)
junk = CheckData(LastRow, strFileName, "UNIT_NUMBER")
junk = CheckData(LastRow, strFileName, "CHAPTER_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "strand"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
junk = CheckData(LastRow, strFileName, "STRAND_NUMBER")
Case "station"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "STATION_NUMBER")
Case "level"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "STATION_NUMBER")
junk = CheckData(LastRow, strFileName, "LEVEL_NUMBER")
Case "day"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
Case "activity"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
junk = CheckData(LastRow, strFileName, "STRAND_NUMBER")
junk = CheckData(LastRow, strFileName, "ACTIVITY_NUMBER")
junk = CheckData(LastRow, strFileName, "STARS_GUID")
Case "resactivity"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "DAY_NUMBER")
junk = CheckData(LastRow, strFileName, "STRAND_NUMBER")
junk = CheckData(LastRow, strFileName, "ACTIVITY_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case "resstationactivity"
junk = CheckData(LastRow, strFileName, "THEME_NUMBER")
junk = CheckData(LastRow, strFileName, "LESSON_NUMBER")
junk = CheckData(LastRow, strFileName, "STATION_NUMBER")
junk = CheckData(LastRow, strFileName, "LEVEL_NUMBER")
junk = CheckData(LastRow, strFileName, "RES_TYPE_ID")
junk = CheckData(LastRow, strFileName, "RES_CAT_ID")
Case Else
MsgBox ("Unrecognized file type. The error checker has not
been " + vbCrLf + _
"adapted to this file type: " + vbCrLf + vbCrLf + vbTab +
vbTab + filetype)
End Select
Module2.SwapToFile (strFileName)
ActiveWorkbook.Close False
End Function
Private Function FindFileName(ByVal fileList As Variant, ByVal
strFileType As String) As Integer
Dim i As Integer
For i = 0 To UBound(fileList)
If fileList(i) = strFileType Then
FindFileName = i + 1
Exit For
End If
Next
End Function
Private Function CheckData(ByVal intBottomOfInfo As Integer, ByVal
strFile As String, ByVal strCol As String)
'Checks the imported column (strCol)to make sure that it conforms to
the correct format of the respective column
'including no inappropriate spaces
Dim test, test2, test3, flag As Boolean
Dim strTemp, strTest, strTest2, strTest3 As String
Select Case strCol
Case "ISBN" 'ISBN column
strTest = "##########"
strTest2 = "#############"
strTest3 = "#########[0-Z]"
Case "SYLLABUS_ITEM_ID", "CONTENT_ID", "BOOK_ID"
'Syllabus_Item_ID, Content_ID, Book_ID
strTest =
"[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]"
+ _
"[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]"
strTest2 = strTest
strTest3 = strTest
Case "STARS_GUID" 'Stars_GUID
strTest =
"[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]-[0-Z][0-Z][0-Z][0-Z]-[0-Z][0-Z][0-Z][0-Z]-"
+ _
"[0-Z][0-Z][0-Z][0-Z]-[0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]"
strTest2 = strTest
strTest3 = strTest
Case "PACING" 'Pacing
strTest = "#"
strTest2 = "#.#"
strTest3 = "##.#"
Case "RES_TYPE_ID", "RES_CAT_ID" 'RESOURCE IDs
junk = CheckRES_ID(intBottomOfInfo, strCol, strFile)
Exit Function
Case Else 'Any plain
numeric column
strTest = "#"
strTest2 = "##"
strTest3 = "###"
End Select
Module2.SwapToFile (strFile)
intColNum = FindWhichColumn(strCol)
For intRowNum = 2 To intBottomOfInfo
flag = True
strTemp = Cells(intRowNum, intColNum).Value2
test = strTemp Like strTest
test2 = strTemp Like strTest2
test3 = strTemp Like strTest3
If Cells(intRowNum, intColNum) = "" Then
strTemp = strFile & ": There is no number in column: " &
strCol & " row: " & intRowNum
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
flag = False
ElseIf (Not test) And (Not test2) And (Not test3) Then
strTemp = strFile & ": Improper number format in column: "
& strCol & " row: " & intRowNum
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
flag = False
End If
If strCol = "ISBN" And flag Then
If Cells(intRowNum, intColNum).Value2 <> Cells(2, 1).Value2
Then
strTemp = strFile & ": There is a differing " & strCol
& " in row: " & intRowNum
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
End If
End If
Next
Module2.SwapToErrorChecker
End Function
Private Function CheckRES_ID(ByVal intBottomOfInfo As Integer, ByVal
strCol As String, ByVal strFile As String)
Dim ResList(50), strTemp As String 'Chose the array to be 50
elements because that would cover both RES lists
Dim intRow, intCol, i, intURICol As Integer 'with some room
for growth.
intRow = 1
Module2.SwapToErrorChecker
Sheets(strCol).Activate
Cells(intRow, 1).Select
While Cells(intRow, 1).Value2 <> ""
ResList(intRow) = Cells(intRow, 1).Value2
intRow = intRow + 1
Wend
ResList(intRow + 1) = "End of List" 'Insert manual EOF
Module2.SwapToFile (strFile)
intRow = 2
intCol = FindWhichColumn(strCol)
intURICol = FindWhichColumn("URI")
For intRow = 2 To intBottomOfInfo
i = 1
Do While ResList(i) <> "End of List"
If Cells(intRow, intCol).Value2 = ResList(i) Then
If ResList(i) = "D661E0B7264D1B55E034080020A7D594" Or
ResList(i) = "D661E0B7264E1B55E034080020A7D594" Then
If Cells(intRow, intURICol).Value2 = "" Then
strTemp = strFile & ": Resource listed without
corresponding URI on row: " & intRow
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 1)
Module2.SwapToFile (strFile)
End If
End If
Exit Do
Else
i = i + 1
End If
If ResList(i) = "End of List" Then
strTemp = strFile & ": Invalid " & strCol & " in row: "
& intRow
Module2.SwapToErrorChecker
junk = InsertNextMessage(strTemp, 0)
Module2.SwapToFile (strFile)
End If
Loop
intRow = intRow + 1
Next
Module2.SwapToErrorChecker
End Function
Private Function FindWhichColumn(ByVal strColName As String) As Integer
Dim intColNum As Integer
intColNum = 1
While Cells(1, intColNum).Value2 <> ""
If Cells(1, intColNum).Value2 = strColName Then
FindWhichColumn = intColNum
Exit Function
End If
intColNum = intColNum + 1
Wend
FindWhichColumn = 255
End Function
Private Function InsertNextMessage(ByVal strError As String, ByVal
choice As Integer)
'Used to insert an error message in the proper location, "Possible
Errors" or "Warnings" based on "choice"
'choice = 0 <--- Possible Error
'choice = 1 <--- Warning
Dim strSearch As String
Select Case choice
Case 0
strSearch = "Possible Errors"
Case 1
strSearch = "Warnings"
End Select
CurrCell = Cells.Find(What:=strSearch, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
If Cells(Selection.Row + 1, 1).Value2 <> "No errors found." Then
'test to see if entering first error/warning
If Cells(Selection.Row + 2, 1).Value2 <> "" Then 'test
to see if entering second error/warning
Selection.End(xlDown).Offset(1, 0).Select
Rows(Selection.Row).Select
Selection.Insert Shift:=xlDown
Cells(Selection.Row, 1).Value2 = strError
Else
Rows(Selection.Row + 2).Select
Selection.Insert Shift:=xlDown
Cells(Selection.Row, 1).Value2 = strError
End If
Else
Cells(Selection.Row + 1, 1).Value2 = strError
Rows(Selection.Row + 2).Select
Selection.Insert Shift:=xlDown
End If
End Function
Private Function IsItReading() As Boolean
Dim isReading As Boolean
intFlag = FindWhichColumn("THEME_NUMBER") 'Test to determine if
it is a reading group if 'THEME_NUMBER' doesn't exist
If intFlag <> 32767 Then 'intFlag is set to
32767
If Cells(2, intFlag).Value2 = "" Then
intFlag = 32767
isReading = False
Else
isReading = True
End If
Else
isReading = False
End If
IsItReading = isReading
End Function
'Module2 Code:
Public Sub SwapToErrorChecker()
Windows("ErrorChecker.xls").Activate
Sheets("Errors").Activate
End Sub
Public Sub SwapToFile(ByVal strFile As String)
Windows(strFile).Activate
Sheets(1).Activate
End Sub