L
LEU
I have the following macro looks for the word ‘NOTE:’ and put’s it into a
table. I would like to modify so that if it comes across the word ‘NOTE:’
that is already in a table, it will resize the table. I know I need to write
it to say: IF ‘WORD:’ is not in a table THEN do the following ELSE do the
following. I have tried a couple of different ways but can’t get it to work.
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
Do While Selection.Find.Execute(Replace:=wdReplaceOne)
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.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
Loop
Endthis:
Selection.HomeKey wdStory
LEU
table. I would like to modify so that if it comes across the word ‘NOTE:’
that is already in a table, it will resize the table. I know I need to write
it to say: IF ‘WORD:’ is not in a table THEN do the following ELSE do the
following. I have tried a couple of different ways but can’t get it to work.
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
Do While Selection.Find.Execute(Replace:=wdReplaceOne)
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.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
Loop
Endthis:
Selection.HomeKey wdStory
LEU