OEM Char
DOS verwendet OEM, Windows benutzt Char. Importiert man OEM - Dateien, werden Sonderzeichen nicht richtig dargestellt. Aber dafür gibt es API-Funktionen, die in beide Richtungen konvertieren.
Unter Punkt 91 finden Sie Code zum Umwandeln von UTF-8 nach
CHAR.
Beispieldatei (oemchar.zip 9 kB)
Option Explicit
Private Declare Function CharToOem _
Lib "user32" Alias "CharToOemA" ( _
ByVal lpszSrc As String, _
ByVal lpszDst As String _
) As Long
Private Declare Function OEMToChar _
Lib "user32" Alias "OemToCharA" ( _
ByVal lpszSrc As String, _
ByVal lpszDst As String _
) As Long
Public Function ToChar(strSource As String) As String
OEMToChar strSource, strSource
ToChar = strSource
End Function
Public Function ToOem(strSource As String) As String
CharToOem strSource, strSource
ToOem = strSource
End Function
Public Sub TabelleNachChar() 'Wandelt Tabelle nach Char um
Dim rngCell As Range
For Each rngCell In Worksheets("Tabelle1").UsedRange
With rngCell
If .Text <> "" Then
If Not .HasFormula Then
If IsNumeric(.Text) = False Then
.Value = ToChar(.Text)
End If
End If
End If
End With
Next
End Sub
'Konvertiert Textdatei
Public Sub TextdateiUmwandeln()
Dim strFile As String
Dim lngFileLen As Long
Dim strText As String
Dim lngFF As Long
strFile = Application.GetOpenFilename( _
"Textdateien (*.csv ; *.txt),*.csv ; *.txt")
If (LCase(strFile) = "falsch") Or _
(LCase(strFile) = "false") Then Exit Sub
lngFF = FreeFile
Open strFile For Binary As lngFF
lngFileLen = LOF(lngFF)
strText = String(lngFileLen, 0)
Get lngFF, , strText
strText = ToChar(strText)
' strText = ToOem(strText)
Put lngFF, 1, strText
Close lngFF
End Sub