Word aus Excel per VBA bearbeiten
11.11.2015 20:18:01
Kai
Ich muss aus Excel ein Word Dokument erzeugen und in dem Dokument per Suchen und ersetzen Text austauschen.
Dazu habe ich folgendes Makro:
Dim appWord As Object
Dim docBericht As Object
Pfad = ActiveWorkbook.Path
Set appWord = CreateObject("Word.Application")
Set docBericht = appWord.Documents.Add(Pfad & "\Bericht.dotx")
appWord.Visible = True
docBericht.Activate
With appWord.Selection.Find
.Text = "Gegenstand"
.Replacement.Text = "xxxxx"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Das Wort Gegenstand wird bei Excecute in Dokument zwar markiert, aber nicht ersetzt.
Ich habe mehrere Variationen probiert, komme aber zu keinem anderen Ergebnis.
Was mache ich falsch.
Danke für die Unterstützung!
Viele Grüße
Kai