How to remove last character from a paragraph

S

Sandusky

I have a document in which every paragraph ends in a comma. I'd like
to replace that comma with a period. How to do this? Is the paragraph
symbol, even though it isn't visible, considered a character of the
paragraph? I was trying to do something like this:

Dim sel As Selection, rng As Range
Set sel = Selection
Set rng = sel.Range

Dim pgs As Paragraphs
Set pgs = rng.Paragraphs

Dim pg As Paragraph, txt As String
Dim i As Long
For i = 1 To pgs.Count
Set pg = pgs(i)
txt = pg.Range.Text
If Right(txt, 1) = "," Then
'do something
pg.Range.Text = newtextvalue
End If
Next i
 
D

dedawson

VBA not required, simple Find and Replace will do it
Find text ,^p
Replace text .^p
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top