ich habe eine Excel-Liste mit ca. 2000 Zeilen. Nun möchte ich,
dass alle Einträge in Spalte A (die da z. B. heissen
G1010001TY) in einem Word-Dokument gesucht werden. Falls der
entsprechende Eintrag in dem Word-Dokument existiert, soll in
Spalte B der entsprechenden Zeile ein X geschrieben werden.
Geht das überhaupt?
Hi Ralph,
in ein Standardmodul:
Option Explicit
'
Sub tt()
' EXtras--Verweise, Verweis auf Microsoft Word X.0 Object Library setzen !!!
Dim appWord As Object, Zei As Long, Wort
On Error Resume Next
Columns(2).ClearContents
Set appWord = GetObject(, "Word.Application")
If Err.Number 0 Then Set appWord = CreateObject("Word.Application")
Err.Clear
On Error GoTo 0
With appWord
'.Visible = True
.Documents.Open "H:\Test.doc"
For Each Wort In .ActiveDocument.Content.Words
If Application.CountIf(Range("A:A"), Trim(Wort)) \> 0 Then
Zei = Application.Match(Trim(Wort), Range("A:A"), 0)
Cells(Zei, 2) = "X"
End If
Next Wort
.Quit
End With
End Sub
Gruß
Reinhard