![]() |
|
#1
|
|||
|
|||
|
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 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 |
|
#2
|
|||
|
|||
|
Self-solved.
Code:
Sub WordCount()
Dim n As Long
n = 0
For Each w In ActiveDocument.Words
w.Select
If UCase$(Left$(w, 1)) Like "[A-Z]" Then
n = n + 1
Debug.Print n
End If
Next
End Sub
|
|
#3
|
||||
|
||||
|
Hi tinfanide,
Try a wildcard Find/Replace, where: Find = <?@> Replace = Text
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#4
|
|||
|
|||
|
Yes, as expected. I've written up codes for such a simple task. Thanks for that.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |