"">"
outRow = outRow + 1
ws.Cells(outRow, "A").Value = "
"
outRow = outRow + 1
ws.Cells(outRow, "A").Value = "- Nicknames
"
outRow = outRow + 1
ws.Cells(outRow, "A").Value = "
"
outRow = outRow + 1
ws.Cells(outRow, "A").Value = BuildAlphabetLinksHtml()
outRow = outRow + 1
ws.Cells(outRow, "A").Value = "
"
outRow = outRow + 1
End Sub
Private Function BuildAlphabetLinksHtml() As String
Dim s As String
Dim i As Long
Dim letterText As String
s = "
"
For i = 65 To 90
letterText = Chr$(i)
If i > 65 Then s = s & " "
s = s & "
" & letterText & ""
Next i
s = s & "
"
BuildAlphabetLinksHtml = s
End Function
Private Sub WriteBottomHtmlBlock(ByVal ws As Worksheet, ByRef outRow As Long)
ws.Cells(outRow, "A").Value = "
"
outRow = outRow + 1
ws.Cells(outRow, "A").Value = ""
outRow = outRow + 1
ws.Cells(outRow, "A").Value = ""
outRow = outRow + 1
End Sub
Private Sub ExportSheetColumnAToUtf8Html(ByVal ws As Worksheet, ByVal outputPath As String)
Dim lastRow As Long
Dim i As Long
Dim txt As String
Dim stm As Object
lastRow = LastUsedRow(ws, "A")
Set stm = CreateObject("ADODB.Stream")
With stm
.Type = 2
.Charset = "utf-8"
.Open
For i = 1 To lastRow
txt = CStr(ws.Cells(i, "A").Value)
.WriteText txt & vbCrLf
Next i
.SaveToFile outputPath, 2
.Close
End With
Set stm = Nothing
End Sub
Private Function GetFolderFromUser(ByVal dialogTitle As String) As String
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Title = dialogTitle
.AllowMultiSelect = False
.InitialFileName = "C:\UDF2\uiFiles\UserItems\"
If .Show = -1 Then
GetFolderFromUser = .SelectedItems(1)
Else
GetFolderFromUser = ""
End If
End With
End Function
Private Function EnsureSheet(ByVal sheetName As String) As Worksheet
On Error Resume Next
Set EnsureSheet = ThisWorkbook.Worksheets(sheetName)
On Error GoTo 0
If EnsureSheet Is Nothing Then
Set EnsureSheet = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count))
EnsureSheet.Name = sheetName
End If
End Function
Private Function LastUsedRow(ByVal ws As Worksheet, ByVal colLetter As String) As Long
Dim n As Long
n = ws.Cells(ws.Rows.Count, colLetter).End(xlUp).Row
If n < 1 Then n = 1
LastUsedRow = n
End Function
Private Function TrimSafe(ByVal v As Variant) As String
If IsError(v) Then
TrimSafe = ""
ElseIf IsNull(v) Then
TrimSafe = ""
Else
TrimSafe = Trim$(CStr(v))
End If
End Function
Private Function IsBadNickname(ByVal nickname As String, ByVal surname As String) As Boolean
nickname = TrimSafe(nickname)
surname = TrimSafe(surname)
If nickname = "" Then
IsBadNickname = True
Exit Function
End If
If surname = "" Then
IsBadNickname = True
Exit Function
End If
If InStr(1, nickname, "?", vbTextCompare) > 0 Then
IsBadNickname = True
Exit Function
End If
If Left$(nickname, 2) = "--" Then
IsBadNickname = True
Exit Function
End If
If Left$(nickname, 1) = "-" Then
IsBadNickname = True
Exit Function
End If
IsBadNickname = False
End Function
Private Function GroupLetterFromText(ByVal s As String) As String
Dim ch As String
s = TrimSafe(s)
If s = "" Then
GroupLetterFromText = "#"
Exit Function
End If
ch = Left$(ExcelUpperText(s), 1)
Select Case ch
Case "Á", "À", "Â", "Ã", "Ä", "Å"
ch = "A"
Case "É", "È", "Ê", "Ë"
ch = "E"
Case "Í", "Ì", "Î", "Ï"
ch = "I"
Case "Ó", "Ò", "Ô", "Õ", "Ö"
ch = "O"
Case "Ú", "Ù", "Û", "Ü"
ch = "U"
Case "Ç"
ch = "C"
Case "Ñ"
ch = "N"
End Select
If ch Like "[A-Z]" Then
GroupLetterFromText = ch
Else
GroupLetterFromText = "#"
End If
End Function
Private Function HtmlEncodeUtf8(ByVal s As String) As String
s = Replace(s, "&", "&")
s = Replace(s, "<", "<")
s = Replace(s, ">", ">")
s = Replace(s, """", """)
HtmlEncodeUtf8 = s
End Function
Private Function BuildDateBracket(ByVal birthDate As String, ByVal deathDate As String) As String
birthDate = TrimSafe(birthDate)
deathDate = TrimSafe(deathDate)
If birthDate = "" And deathDate = "" Then
BuildDateBracket = ""
Else
BuildDateBracket = "(" & HtmlEncodeUtf8(birthDate) & "-" & HtmlEncodeUtf8(deathDate) & ")"
End If
End Function
Private Function ExcelUpperText(ByVal s As String) As String
On Error Resume Next
ExcelUpperText = Application.WorksheetFunction.Upper(s)
If Err.Number <> 0 Then
Err.Clear
ExcelUpperText = s
End If
On Error GoTo 0
End Function