|  
                                             
	Hallo, 
	Ich habe in Word2007, VBA eine Funktion, die im Dokument ein bestimmtes Wort finden und markieren soll. 
	das funktioniert prima für das ganze Dokument. Nun habe ich Versuche gemacht, dass es nur in einer Auswahl gemacht werden soll... 
	Das hab ich nicht hingekriegt, vielleicht gibt's hier Hilfe? 
	Hier der derzeitige Code: 
Sub SelectionFind(rng As Range, strFind As String, col As Long)
    With rng.Find
         Do
            .ClearFormatting
            .text = strFind
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = True
            .MatchWholeWord = True
            If .Execute = True Then
'                MsgBox ("Text found.")
                rng.Select
                selection.Shading.ForegroundPatternColor = wdColorAutomatic
                selection.Shading.BackgroundPatternColor = col
            Else
'                MsgBox ("The text could not be located.")
                Exit Do
            End If
        Loop
    End With
End Sub
	Aufruf: 
	  
    Dim oRng As Range
    Set oRng = selection.Range
    SelectionFind oRng, TextBox1.text, color.BackColor
	(color ist eine ImageBox) 
	Grüße- 
	Dietrich 
     |