Delete every other character

R

Rene

I have a document that was a conversion from PDF to RTF. For some reason the
text duplicated itself in the conversion process. So instead of showing "The
dog was hungry." is displays ""TThhee ddoogg wwaass hhuunnggrryy.."" Can
anyone help me with a macro that will delete every other character? If it
helps, the font color also alternates between black and gray. Thanks!
 
D

Doug Robbins - Word MVP

Hi Rene,

Use the following code:

Dim aword As Range, i As Integer, j As Integer, neword As String
For i = 1 To ActiveDocument.Words.Count
Set aword = ActiveDocument.Words(i)
neword = ""
For j = 1 To aword.Characters.Count Step 2
neword = neword & aword.Characters(j)
Next j
aword = neword
Next i

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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