Hallo BH8,
hier eine kleine Funktion:
Public Function FirstLetter(ausdruck As String) As String
Dim ausnahmen, trennzeichen, worte, wort, tz
Dim newWords As String
ausnahmen = Array("von", "und", "zu")
trennzeichen = Array(" ", "-")
strWork = ausdruck
For Each tz In trennzeichen
newWords = ""
worte = Split(strWork, tz)
For Each wort In worte
noChange = False
For Each ausnahme In ausnahmen
If wort = ausnahme Then
noChange = True
Exit For
End If
Next
If noChange Then
newWords = IIf(newWords = "", wort, newWords & tz & wort)
Else
newWord = UCase(Left(wort, 1)) & Mid(wort, 2)
newWords = IIf(newWords = "", newWord, newWords & tz & newWord)
End If
Next
strWork = newWords
Next
FirstLetter = strWork
End Function
Public Sub TestFirstLetter()
MsgBox (FirstLetter("dr. marc von Moechte-nicht"))
End Sub
Grüße Lutz
|