Hallo,
relativ einfach. Dazu legst du dir eine ganz normale TXT-Datei an. In die schreibst du
SuchText;ErsetzenText
präsentiert waren;präsentiert wurden
waren präsentiert;wurden präsentiert
Wie man sieht, ganz einfach. Das Speichern nicht vergessen.
Ich habe meiner TXT den Namen CD.txt gegeben und habe sie in "C:\CustomDictionary\" abgespeichert.
Dann diesen Code verwenden ...
Private DIC_ARRAY() As String
Private Sub READ_CSV_ARRAY()
Dim fnam As String
Dim f As Integer
Dim fi As String
Dim ln As Variant
Dim fln As Variant
Dim row As Long
Dim col As Long
Dim arr() As String
Dim l As Long
Dim cl As Long
Dim i As Long
Dim Suchtext As String
Dim Ersetzung As String
Dim adoStream As Object
fnam = "C:\CustomDictionary\CD.txt" '<-- ANPASSEN ... falls du wo anders speicherst !!!
Set adoStream = CreateObject("ADODB.Stream")
adoStream.Charset = "UTF-8"
adoStream.Open
adoStream.LoadFromFile fnam
fi = adoStream.ReadText
adoStream.Close
Set adoStream = Nothing
ln = Split(fi, vbCrLf)
row = UBound(ln)
fln = Split(ln(0), ";")
col = UBound(fln)
ReDim arr(row, col)
For l = 0 To row
If Len(ln(l)) > 0 Then
fln = Split(ln(l), ";")
For cl = 0 To col
arr(l, cl) = fln(cl)
Next cl
End If
Next l
DIC_ARRAY() = arr()
For i = LBound(DIC_ARRAY) To UBound(DIC_ARRAY)
Suchtext = DIC_ARRAY(i, 0)
Ersetzung = DIC_ARRAY(i, 1)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = Suchtext
.Replacement.Text = Ersetzung
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
End Sub
Sabina
|