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
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