View Single Post
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Macro recorder not recording properly

The macro recorder, as others have suggested, cannot cope with this type of
action. You would need to create a roll-your-own function that would process
each found item separately. It seems that you want to insert all the found
items at the start of your document. The following macro will do that, with
each item separated by a comma and a space:

Dim oRng As Range
Dim sText As String
Dim sFound As String
sFound = ""
sText = InputBox("Enter the string to process")
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:=sText, _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set oRng = Selection.Range
sFound = sFound & oRng.Text & ", "
Loop
End With
If Len(sFound) 0 Then
sFound = Left(sFound, Len(sFound) - 2)
ActiveDocument.Range.InsertBefore sFound & vbCr
Else
MsgBox "Item not found", vbInformation, "Find text"
End If

http://www.gmayor.com/installing_macro.htm

"Al Almoian" wrote in message
3...
Word 2003. I do a wildcard Find Highlight all then copy, ctrlHome,paste,
it works great. But when I try to macro record this sequence it does not
work. The debug on the Copy statement says nothing is selected. And the
macro only has Find, not Find All. How do I fix this?