RonNCmale
05-14-2013, 07:51 AM
Need code added to stop search when the end of document is reached.
Thanks in advance
Sub findInOpenDocuments()
Dim dlg As Word.Dialog
Dim doc As Word.Document
Dim f As Word.Find
Dim g As Word.Find
Dim strName As String
' this might not be quite enough...
strName = ActiveDocument.Name
Set dlg = Word.Dialogs(wdDialogEditFind)
dlg.Show
Set dlg = Nothing
' at this point, we have all the stuff we need to find/highlight
' the same texts in all the other documents
For Each doc In Word.Documents
If doc.Name <> strName Then
doc.Select
With Selection.Find
.ClearHitHighlight
.HitHighlight findtext:=Selection.Find.Text, highlightcolor:=WdColor.wdColorAqua
End With
End If
Next
End Sub
Thanks in advance
Sub findInOpenDocuments()
Dim dlg As Word.Dialog
Dim doc As Word.Document
Dim f As Word.Find
Dim g As Word.Find
Dim strName As String
' this might not be quite enough...
strName = ActiveDocument.Name
Set dlg = Word.Dialogs(wdDialogEditFind)
dlg.Show
Set dlg = Nothing
' at this point, we have all the stuff we need to find/highlight
' the same texts in all the other documents
For Each doc In Word.Documents
If doc.Name <> strName Then
doc.Select
With Selection.Find
.ClearHitHighlight
.HitHighlight findtext:=Selection.Find.Text, highlightcolor:=WdColor.wdColorAqua
End With
End If
Next
End Sub