I have a form with 20 text templates which are being inserted in to a textbox, each one with it's own button "Text 1", "Text 2", ... "Text 20". Up to "Text 17" it's working properly, but from "Text 18" German umlauts appear wrong. For example:
Text files 16 - 20 contains the number of the text and "abc öäüß". pressing text 16 or 17 buttons restlts with "abc öäüß" in the textbox, but pressing text 18 and above, results with "abc öäüß" in the text box.
All buttons use the same code:
Button 17 code: getDatei (17)
Button 18 code: getDatei (18)
Public Sub getDatei(BtnNum As Integer)
Dim text As String
text = GetText("EmailVorlage" & BtnNum & Forms!EmailVersand.mstrSprache & ".txt")
If text & "" <> "" Then
Forms!EmailVersand.TextFeld = text
Else
If FileExists(Forms!Startformular!txtPfad & "emaildateien\" & _
"EmailVorlage" & BtnNum & Forms!EmailVersand.mstrSprache & ".txt") = False Then
txt_erstellen Forms!Startformular!txtPfad & "emaildateien\" & _
"EmailVorlage" & BtnNum & Forms!EmailVersand.mstrSprache & ".txt", _
BtnNum & Forms!EmailVersand.mstrSprache
End If
End If
End Sub
Public Function GetText(fName As String, Optional strPfad As String) As String
Dim intDatei As Integer
Dim strText As String
Dim strAnr As String
On Error GoTo Err
intDatei = FreeFile
If strPfad = "" Then
strPfad = Forms!Startformular!txtVorlagenPfad & GetPartFileName(CurrentDb.Name, bbGetName)
If Screen.ActiveControl.Parent.Name = "EmailVersand" And Screen.ActiveControl.Name Like "EmailButton*" Then
strPfad = Forms!Startformular!txtVorlagenPfad & "TA_VBemails\"
End If
End If
If Right(strPfad, 1) <> "\" Then strPfad = strPfad & "\"
Open strPfad & fName For Input As intDatei
strText = Input(LOF(intDatei), intDatei)
Close intDatei
GetText = strText
Exit Function
Err:
GetText = ""
MsgBox Err.Description
End Function
Any idea why this happens only with buttons 18 and above?
I tried to create new text files, swap the content of text 16 and 18, swap file names of text 16 and 18.
I solved it by saving the text file with ANSI format instead of UTF-8.