I've tried some of the find & replace macros mentioned at various times in
the discussion groups and they do seem to be rather unreliable with certain
complicated documents.
This one, which I copied from a link, seemed to one of the most
straightforward and runs on most documents but sometimes ends up in an
endless loop in certain cases with text boxes inside what I think is a frame
(hatched box which you can't seem to resize).
Any idea what can be going wrong or how I can diagnosis the problem?
Sub FasterResetSpacing()
Application.ScreenUpdating = False
Dim spacingStoryRange As Range
'First search the main document using the Selection
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^?"
.Replacement.Text = "^&"
.Forward = True
.Format = True
.Replacement.Font.Spacing = 0
.Replacement.Font.Scaling = 100
.Replacement.Font.Position = 0
.Replacement.Font.Kerning = 0
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
'Now search all other stories using Ranges
For Each spacingStoryRange In ActiveDocument.StoryRanges
If spacingStoryRange.StoryType <> wdMainTextStory Then
With spacingStoryRange.Find
.Text = "^?"
.Replacement.Text = "^&"
.Format = True
.Replacement.Font.Spacing = 0
.Replacement.Font.Scaling = 100
.Replacement.Font.Position = 0
.Replacement.Font.Kerning = 0
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Do While Not (spacingStoryRange.NextStoryRange Is Nothing)
Set spacingStoryRange = spacingStoryRange.NextStoryRange
With spacingStoryRange.Find
.Text = "^?"
.Replacement.Text = "^&"
.Format = True
.Replacement.Font.Spacing = 0
.Replacement.Font.Scaling = 100
.Replacement.Font.Position = 0
.Replacement.Font.Kerning = 0
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Loop
End If
Next spacingStoryRange
End Sub
Any help much appreciated.
David Turner