B
BP
Dear friends,
My problem is that I want to find each range formatted as
bold in a document and insert something at the beginning and
end of the range, which I did like so:
* Selection.Find.ClearFormatting
* Selection.Find.Replacement.ClearFormatting
* With Selection.Find
* .Font.Bold = True
* .Text = ""
* .Replacement.Font.Bold = True
* .Replacement.Text = "*^&*"
* .Forward = True
* .Wrap = wdFindContinue
* .Format = True
* End With
* Selection.Find.Execute Replace:=wdReplaceAll
Now the problem is that if the last character of the range
is a paragraph mark this mark is included and the closing
"*" ends up at the beginning of the next paragraph. I can
*not* fix it with:
* Selection.Find.ClearFormatting
* Selection.Find.Replacement.ClearFormatting
* With Selection.Find
* .Font.Bold = True
* .Text = "^p*"
* .Replacement.Text = "*^p"
* .Forward = True
* .Wrap = wdFindContinue
* .Format = True
* .MatchCase = False
* End With
* Selection.Find.Execute Replace:=wdReplaceAll
because in some cases there should be a "*" at the beginning
of a paragraph, and that should not be shifted to the end of
the preceding paragraph.
So what I need to do is to check if the last character of
the found range is a paragraph mark, and if it is insert the
"*" before the paragraph mark, but else just insert a "*" at
the end of the range.. How can I do that?
TIA,
/BP
My problem is that I want to find each range formatted as
bold in a document and insert something at the beginning and
end of the range, which I did like so:
* Selection.Find.ClearFormatting
* Selection.Find.Replacement.ClearFormatting
* With Selection.Find
* .Font.Bold = True
* .Text = ""
* .Replacement.Font.Bold = True
* .Replacement.Text = "*^&*"
* .Forward = True
* .Wrap = wdFindContinue
* .Format = True
* End With
* Selection.Find.Execute Replace:=wdReplaceAll
Now the problem is that if the last character of the range
is a paragraph mark this mark is included and the closing
"*" ends up at the beginning of the next paragraph. I can
*not* fix it with:
* Selection.Find.ClearFormatting
* Selection.Find.Replacement.ClearFormatting
* With Selection.Find
* .Font.Bold = True
* .Text = "^p*"
* .Replacement.Text = "*^p"
* .Forward = True
* .Wrap = wdFindContinue
* .Format = True
* .MatchCase = False
* End With
* Selection.Find.Execute Replace:=wdReplaceAll
because in some cases there should be a "*" at the beginning
of a paragraph, and that should not be shifted to the end of
the preceding paragraph.
So what I need to do is to check if the last character of
the found range is a paragraph mark, and if it is insert the
"*" before the paragraph mark, but else just insert a "*" at
the end of the range.. How can I do that?
TIA,
/BP