Re-Arranging Text

A

Alan

I wish to re-arrange the text on screen so that the
word "erutan" becomes "nature". I know i can perform this
task within Clip-art, however i want to edit the text
within the word document.

Please assist!

Thanks
 
D

Doug Robbins - Word MVP

Hi Alan,

Use a macro containing the following code to reverse the letters in the
selected word :

Dim j As Integer, i As Integer, m As String, n As String
j = Selection.Words(1).Characters.Count
For i = 1 To Int(j / 2)
m = Selection.Words(1).Characters(i)
n = Selection.Words(1).Characters(j - i + 1)
Selection.Words(1).Characters(i) = n
Selection.Words(1).Characters(j - i + 1) = m
Next i

If you want to do it to every word in the document, use

Dim j As Integer, i As Integer, k As Integer, m As String, n As String,
myrange As Range
For k = 1 To ActiveDocument.Words.Count
Set myrange = ActiveDocument.Words(k)
myrange.End = myrange.End - 1
j = myrange.Characters.Count
For i = 1 To Int(j / 2)
m = myrange.Characters(i)
n = myrange.Characters(j - i + 1)
myrange.Characters(i) = n
myrange.Characters(j - i + 1) = m
Next i
Next k

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