Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-20-2012, 05:12 AM
tinfanide tinfanide is offline Select word by word Windows 7 64bit Select word by word Office 2010 32bit
Expert
Select word by word
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Select word by word

I wonder how I can replace every word in a document with some texts:



Document:

Apple
Cat

Replace every of them like:

Text
Text

Code:
Sub test()

For w = 1 To ActiveDocument.Words.Count
ActiveDocument.Words(w).Select
' fail to exclude the space following the selected word
If Not Selection.Text Like " *" Then
Selection.Text = "Text"
End If
Next w

End Sub
But this code just ends up like

Doc:
Text Text

It moves the second one up to the first paragraph
And I'm stuck at how to get rid of the space following the word
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Select word by word Select all textboxes in Word document msword270 Word 1 01-12-2012 11:41 AM
Unable to select anything in an MS Word Document PaulT Word 0 08-08-2011 07:45 PM
Select word by word Word XP - Can't select line RogerM Word 2 03-11-2011 01:26 PM
Force to select a group of word? jakekei Word 0 01-21-2010 04:20 PM
How to write in Word from Select query lakhan.p Word 0 03-27-2009 07:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:32 AM.


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