I was searching today for a VBA script to take care of those words that are not supposed to be capitalized in the title of a book. I work in a library, and am typing them on a regular basis.
I could not find one that was any good. So I gave up and wrote on myself (I hope others will put it to use):
Private Function TitleCase(Title)
Dim OriginalBookName As String
Dim BookNameHold As String
Dim BookNameHold2 As String
Dim One As String
Dim Two As String
Dim SearchWord As String
Dim FoundOne As Boolean
Dim BookName As String
If IsNull(Title) = True Or Title = "" Then Exit Function
BookName = Title
DoubleSpace:
If InStr(1, BookName, " ") > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, " ")) & Mid(BookName, InStr(1, BookName, " ") + 2, 100000)
GoTo DoubleSpace
End If
OriginalBookName = Trim(BookName)
BookName = " " & LCase(BookName) & " "
Topper2:
If InStr(1, Mid(BookName, 1, 1), UCase(Mid(BookName, 1, 1)), 0) > 0 And Not Mid(BookName, 1, 1) = "'" Then
BookNameHold2 = BookNameHold2 & " "
Else
BookNameHold2 = BookNameHold2 & Mid(BookName, 1, 1)
End If
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo Topper2
BookName = BookNameHold2
Topper:
One = Mid(BookName, 1, 2)
Two = UCase(Mid(BookName, 1, 1)) & Mid(BookName, 2, 1)
If InStr(1, One, Two, 0) > 0 And Not Mid(BookName, 1, 1) = "'" Then
BookNameHold = BookNameHold & UCase(Mid(BookName, 2, 1))
Else
BookNameHold = BookNameHold & Mid(BookName, 2, 1)
End If
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo Topper
BookName = BookNameHold
TheTopps:
FoundOne = False
SearchWord = " A "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Aboard "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " About "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Above "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Across "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " After "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Against "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Along "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Amid "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Among "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " An "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " And "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Anti "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Around "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " As "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " At "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Before "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Behind "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Below "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Beneath "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Beside "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Besides "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Between "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Beyond "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " But "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " By "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Concerning "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Considering "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Despite "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Down "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " During "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Except "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Excepting "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Excluding "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Following "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " For "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " From "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " In "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Inside "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Into "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Like "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Minus "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Near "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Nor "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Of "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Off "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " On "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Onto "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Opposite "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Or "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Outside "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Over "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Past "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Per "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Plus "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Regarding "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Round "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Save "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Since "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Than "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " The "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Through "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " To "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Toward "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Towards "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Under "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Underneath "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Unlike "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Until "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Up "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Upon "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Versus "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Via "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Vs "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " With "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Within "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Without "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
If FoundOne = True Then GoTo TheTopps
Dim counter As Integer
LastOne:
counter = counter + 1
If Mid(BookName, Len(BookName) - counter, 1) = " " Then
BookName = Mid(BookName, 1, Len(BookName) - counter) & UCase(Mid(BookName, Len(BookName) - counter + 1, 1)) & Mid(BookName, Len(BookName) - counter + 2, 1000000)
Else
GoTo LastOne
End If
BookName = Trim(BookName)
Dim PutBackIn As String
TheTopAgain:
If Mid(BookName, 1, 1) = " " Then
PutBackIn = PutBackIn & Mid(OriginalBookName, 1, 1)
Else
PutBackIn = PutBackIn & Mid(BookName, 1, 1)
End If
OriginalBookName = Mid(OriginalBookName, 2, 1000000)
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo TheTopAgain
BookName = " " & PutBackIn & " "
counter = 0
LastOne2:
counter = counter + 1
If Mid(BookName, Len(BookName) - counter, 1) = " " Then
BookName = Mid(BookName, 1, Len(BookName) - counter) & UCase(Mid(BookName, Len(BookName) - counter + 1, 1)) & Mid(BookName, Len(BookName) - counter + 2, 1000000)
Else
GoTo LastOne2
End If
BookName = Trim(BookName)
'BookName = BookNameHold2
BookName = Trim(BookName)
BookName = UCase(Mid(BookName, 1, 1)) & Mid(BookName, 2, 100000)
Dim Titlebuilder As String
FindCols:
If Mid(BookName, 1, 2) = ": " Then BookName = UCase(Mid(BookName, 1, 3)) & Mid(BookName, 4, 100000)
Titlebuilder = Titlebuilder & Mid(BookName, 1, 1)
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo FindCols
Title = Titlebuilder
End Function
I could not find one that was any good. So I gave up and wrote on myself (I hope others will put it to use):
Private Function TitleCase(Title)
Dim OriginalBookName As String
Dim BookNameHold As String
Dim BookNameHold2 As String
Dim One As String
Dim Two As String
Dim SearchWord As String
Dim FoundOne As Boolean
Dim BookName As String
If IsNull(Title) = True Or Title = "" Then Exit Function
BookName = Title
DoubleSpace:
If InStr(1, BookName, " ") > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, " ")) & Mid(BookName, InStr(1, BookName, " ") + 2, 100000)
GoTo DoubleSpace
End If
OriginalBookName = Trim(BookName)
BookName = " " & LCase(BookName) & " "
Topper2:
If InStr(1, Mid(BookName, 1, 1), UCase(Mid(BookName, 1, 1)), 0) > 0 And Not Mid(BookName, 1, 1) = "'" Then
BookNameHold2 = BookNameHold2 & " "
Else
BookNameHold2 = BookNameHold2 & Mid(BookName, 1, 1)
End If
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo Topper2
BookName = BookNameHold2
Topper:
One = Mid(BookName, 1, 2)
Two = UCase(Mid(BookName, 1, 1)) & Mid(BookName, 2, 1)
If InStr(1, One, Two, 0) > 0 And Not Mid(BookName, 1, 1) = "'" Then
BookNameHold = BookNameHold & UCase(Mid(BookName, 2, 1))
Else
BookNameHold = BookNameHold & Mid(BookName, 2, 1)
End If
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo Topper
BookName = BookNameHold
TheTopps:
FoundOne = False
SearchWord = " A "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Aboard "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " About "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Above "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Across "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " After "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Against "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Along "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Amid "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Among "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " An "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " And "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Anti "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Around "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " As "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " At "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Before "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Behind "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Below "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Beneath "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Beside "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Besides "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Between "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Beyond "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " But "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " By "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Concerning "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Considering "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Despite "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Down "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " During "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Except "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Excepting "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Excluding "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Following "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " For "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " From "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " In "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Inside "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Into "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Like "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Minus "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Near "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Nor "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Of "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Off "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " On "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Onto "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Opposite "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Or "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Outside "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Over "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Past "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Per "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Plus "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Regarding "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Round "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Save "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Since "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Than "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " The "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Through "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " To "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Toward "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Towards "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Under "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Underneath "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Unlike "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Until "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Up "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Upon "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Versus "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Via "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Vs "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " With "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Within "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
SearchWord = " Without "
If InStr(1, BookName, SearchWord, 0) > 0 Then
BookName = Mid(BookName, 1, InStr(1, BookName, SearchWord, 0) - 1) & LCase(SearchWord) & Mid(BookName, InStr(1, BookName, SearchWord, 0) + Len(SearchWord), 1000000)
FoundOne = True
End If
If FoundOne = True Then GoTo TheTopps
Dim counter As Integer
LastOne:
counter = counter + 1
If Mid(BookName, Len(BookName) - counter, 1) = " " Then
BookName = Mid(BookName, 1, Len(BookName) - counter) & UCase(Mid(BookName, Len(BookName) - counter + 1, 1)) & Mid(BookName, Len(BookName) - counter + 2, 1000000)
Else
GoTo LastOne
End If
BookName = Trim(BookName)
Dim PutBackIn As String
TheTopAgain:
If Mid(BookName, 1, 1) = " " Then
PutBackIn = PutBackIn & Mid(OriginalBookName, 1, 1)
Else
PutBackIn = PutBackIn & Mid(BookName, 1, 1)
End If
OriginalBookName = Mid(OriginalBookName, 2, 1000000)
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo TheTopAgain
BookName = " " & PutBackIn & " "
counter = 0
LastOne2:
counter = counter + 1
If Mid(BookName, Len(BookName) - counter, 1) = " " Then
BookName = Mid(BookName, 1, Len(BookName) - counter) & UCase(Mid(BookName, Len(BookName) - counter + 1, 1)) & Mid(BookName, Len(BookName) - counter + 2, 1000000)
Else
GoTo LastOne2
End If
BookName = Trim(BookName)
'BookName = BookNameHold2
BookName = Trim(BookName)
BookName = UCase(Mid(BookName, 1, 1)) & Mid(BookName, 2, 100000)
Dim Titlebuilder As String
FindCols:
If Mid(BookName, 1, 2) = ": " Then BookName = UCase(Mid(BookName, 1, 3)) & Mid(BookName, 4, 100000)
Titlebuilder = Titlebuilder & Mid(BookName, 1, 1)
BookName = Mid(BookName, 2, 1000000)
If Len(BookName) > 0 Then GoTo FindCols
Title = Titlebuilder
End Function