Word 2007 Not responding

F

Fuzzhead

I have the following macro that works fine in Word 2003. But when I try and
run it Word 2007 it locks up. I do not get an error message, Word 2007 just
stops responding. Any help would be appreciated.

On Error GoTo endthis
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.Alignment = wdAlignParagraphLeft
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

With Selection.Find
..Text = "NOTE:^w"
..Replacement.Text = "NOTE:^t"
..Format = False
..Forward = True
..Wrap = wdFindStop
End With
Selection.Find.Execute Replace:=wdReplaceAll
Do While Selection.Find.Execute(Replace:=wdReplaceOne)
If Selection.Information(wdWithInTable) Then
With Selection.ParagraphFormat
.KeepWithNext = True
.KeepTogether = True
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
Selection.Collapse Direction:=wdCollapseEnd
Else
If Not Selection.Information(wdWithInTable) Then
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.Alignment = wdAlignParagraphLeft
End With
Selection.Font.Underline = wdUnderlineNone
Selection.Words(1).Font.Underline = wdUnderlineSingle
Selection.Paragraphs(1).Range.Select
Selection.ConvertToTable Separator:=wdSeparateByParagraphs, NumRows:=1,
numColumns:=1, _
DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:=wdAutoFitFixed
Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
RulerStyle:=wdAdjustNone
Selection.ParagraphFormat.Style = "tlNormal"
Selection.ParagraphFormat.TabStops(InchesToPoints(0.5)).Position = _
InchesToPoints(0.63)
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.63)
.KeepWithNext = True
.KeepTogether = True
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
With Selection.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = InchesToPoints(-0.63)
End With
Selection.Collapse Direction:=wdCollapseEnd
End If

End If
Loop
endthis:
Selection.HomeKey wdStory
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

If Then Else question 3
Multiple Tables 2
Find and Replace Question 3
TOC Help 0
TOC Problem 0
Table of Content 1
Table resizing 2
A macro to increase line spacing 1

Top