Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-07-2014, 08:28 AM
Dimsok Dimsok is offline Reversing text Windows XP Reversing text Office 2007
Advanced Beginner
Reversing text
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default Reversing text

I have a script for reversing letters in words

Sub ReverseWords()
Dim i As Long
Dim OldString As Variant
Dim RevText As Variant
OldString = Split(Selection.Text, " ")
For i = 0 To UBound(OldString)
OldString(i) = StrReverse(OldString(i))
Next
RevText = Join(OldString, " ")
MsgBox RevText
End Sub



But the result just show in message window. Is that possible to change that code that reversed text replaced marked text?
Reply With Quote
  #2  
Old 09-07-2014, 03:35 PM
macropod's Avatar
macropod macropod is offline Reversing text Windows 7 64bit Reversing text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Replace:
MsgBox RevText
with:
Selection.Text = RevText
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-07-2014, 10:52 PM
Dimsok Dimsok is offline Reversing text Windows XP Reversing text Office 2007
Advanced Beginner
Reversing text
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

Thanks. Is that possible to do something for reversing order of words in the sentence?
Reply With Quote
  #4  
Old 09-07-2014, 11:20 PM
macropod's Avatar
macropod macropod is offline Reversing text Windows 7 64bit Reversing text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use something like:
Code:
Sub Reverse()
Dim i As Long
Dim OldString As Variant
Dim RevText As Variant
OldString = Split(Selection.Text, " ")
For i = 0 To UBound(OldString)
  RevText = OldString(i) & " " & RevText
Next
Selection.Text = RevText
 End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-08-2014, 12:48 AM
Dimsok Dimsok is offline Reversing text Windows XP Reversing text Office 2007
Advanced Beginner
Reversing text
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

Thanks a lot
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare text from Bookmark with text from Text box Byron Polk Word VBA 4 07-30-2014 06:18 AM
Reversing Formatted Fractions? Rusty123 Word 1 03-05-2012 05:44 PM
Column/row reversing in excel pban92 Excel 2 01-26-2011 12:00 PM
Reversing text Reverse animation when reversing through slides clients PowerPoint 1 09-28-2010 08:49 PM
Reversing text Reversing Text Order weemikey Word 4 08-05-2009 11:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:59 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft