Find first Word but ignore if it is x

  • Thread starter Thread starter Steved
  • Start date Start date
S

Steved

Hello from Steved

I am building a macro to find the first Word
Please how do I write the macro to ignore the letter x

2. 111x9 Our Front Line
3. x6028 Aqua Meadow
3. 15x73 La Strada

From the above and after writing the macro it should
return the below

Our Front Line
Aqua Meadow
La Strada

Thankyou and Season Grettings to you all.
 
G'day "Steved" <[email protected]>,


For each aWord in aParagraph.Words
if instr(1,aWord.text,"x") then
'bad word
else
'good word
end if
next

But really, I think you should be testing for the presence of numerics
:-)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Steved reckoned:
 
Thankyou.
-----Original Message-----
G'day "Steved" <[email protected]>,


For each aWord in aParagraph.Words
if instr(1,aWord.text,"x") then
'bad word
else
'good word
end if
next

But really, I think you should be testing for the presence of numerics
:-)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Steved reckoned:


.
 
Hello from Steved

You kindly suguested that I test for numerics

Would you please write a macro that would find the first
word and delete the numerics

Thankyou.
 
Hi Steved,

I think what you want to do is to cut off the leftmost text
in the paragraph (if is is a paragraph) including the second space.

Like this, which could be much shorter,
but might be more difficult to understand then for a beginner.
Put the cursor in one of the paragraphs in question.

Dim s As String
Dim p As Integer
Selection.Paragraphs(1).Range.Select
s = Selection.Text
p = InStr(1, s, " ") ' position of 1st space
p = InStr(p + 1, s, " ") ' position of 2nd space
s = Right(s, Len(s) - p) ' text right of position
Selection.Paragraphs(1).Range.Text = s

You may change it to your needs, like processing
all paragraphs in a doc or all paragraphs in the
selection or whatever.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
Thankyou

Yes I am a beginner in word but I can follow what you
have given me.
 

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

Back
Top