VBA-makro: Excel zu Word-text-Ersatz

Gibt es einfache VBA-Makros für Excel (2003). Es so Aussehen zu Zelle A$N B$N, und ersetzen in Word-Dokument text von B$N A$N.

Sub Макрос1()

Dim pathh As String, i As Integer
pathh = "c:\1.doc"
Dim pathhi As String
Dim from_text As String, to_text As String
Dim WA As Object, WD As Object
Set WA = CreateObject("Word.Application")
WA.Documents.Open (pathh)
WA.Visible = True

For oCell = 1 To 150
    from_text = Range("B" + CStr(oCell)).Value
    to_text = Range("A" + CStr(oCell)).Value
    With WA
        .Activate
        With .Selection.Find
          .ClearFormatting
          .Replacement.ClearFormatting

          .Text = from_text
          .Replacement.Text = to_text
          .Execute Replace:=wdReplaceAll
        End With
    End With
Next
End Sub

Problem: im Word-Dokument das Skript wählen Sie nur text, aber keine Ersatz. Nein Vorschlag?

  • Sie haben I dimensioniert und verwenden oCell statt
InformationsquelleAutor potapuff | 2012-12-11
Schreibe einen Kommentar