S
Steve D
I'm doing some capitalization processing on the first paragraph in a
document. One process step may result in a trailing space being added to the
last word in the paragraph. I want to remove the trailing space. I've tried
two approaches without success. Can you see what's wrong with these
approaches?
Approach 1:
NumWords is the number of words in the first line; i is a counter that
iterates over all the words in the first paragraph. In other words, if I'm
on the last word, replace it with a RTrim'd word.
If i = NumWords Then .Words(i) = RTrim(.Words(i))
Approach 2:
Instead of Approach #1, just RTrim the entire first paragraph whether
there's a space there or not.
ActiveDocument.Paragraphs(1).Range =
RTrim(ActiveDocument.Paragraphs(1).Range)
TIA, Steve
document. One process step may result in a trailing space being added to the
last word in the paragraph. I want to remove the trailing space. I've tried
two approaches without success. Can you see what's wrong with these
approaches?
Approach 1:
NumWords is the number of words in the first line; i is a counter that
iterates over all the words in the first paragraph. In other words, if I'm
on the last word, replace it with a RTrim'd word.
If i = NumWords Then .Words(i) = RTrim(.Words(i))
Approach 2:
Instead of Approach #1, just RTrim the entire first paragraph whether
there's a space there or not.
ActiveDocument.Paragraphs(1).Range =
RTrim(ActiveDocument.Paragraphs(1).Range)
TIA, Steve