F
Fuzzhead
I have the following macro that finds the word ‘NOTE’ in the document and
creates a Note Box. How do I get the text that follows the word NOTE and move
it into my Note Box once it is created?
Example of what I have:
NOTE: A does not have Open or Close indication when operated from B.
What I would like it to look like:
NOTE: A does not have Open or Close indication when operated from B
(Inside my Box)
Sub ConvertNotes()
On Error GoTo Endthis
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "NOTE:"
.Replacement.Text = ""
.Format = False
.Forward = True
.Wrap = wdFindStop
End With
Do While Selection.Find.Execute(Replace:=wdReplaceOne)
ActiveDocument.Tables.Add Range:=Selection.Range, 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
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:="NOTE"
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:=":"
Selection.TypeText Text:=" "
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.63)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
With Selection.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = InchesToPoints(-0.63)
End With
Loop
Endthis:
End Sub
creates a Note Box. How do I get the text that follows the word NOTE and move
it into my Note Box once it is created?
Example of what I have:
NOTE: A does not have Open or Close indication when operated from B.
What I would like it to look like:
NOTE: A does not have Open or Close indication when operated from B
(Inside my Box)
Sub ConvertNotes()
On Error GoTo Endthis
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "NOTE:"
.Replacement.Text = ""
.Format = False
.Forward = True
.Wrap = wdFindStop
End With
Do While Selection.Find.Execute(Replace:=wdReplaceOne)
ActiveDocument.Tables.Add Range:=Selection.Range, 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
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:="NOTE"
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:=":"
Selection.TypeText Text:=" "
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.63)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
With Selection.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = InchesToPoints(-0.63)
End With
Loop
Endthis:
End Sub