Remove all captial words from a paragraph

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
rusty9075
Newbie
Posts: 14
Joined: Sun Aug 27, 2006 4:46 pm

Remove all captial words from a paragraph

Post by rusty9075 » Sat Mar 24, 2007 2:51 pm

Hi

I need to create a macro that will remove all capitalized words from a selected text. For example I need to make a macro that would change:
"He went with Sue to Barringer's grocery store to buy Jensen pickles"
to...
"went with to grocery store to buy pickles"

Does anyone know how to use macro scheduler to do this?
Please let me know :)
Thanks

Nate

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Sat Mar 24, 2007 8:53 pm

Pickles!

One way to approach this task is to start by creating some rough logic on what the code would do.

Starting from position 1.
Let>k=1

Loop through (start at 1, see Repeat/Until, or Goto/Label).....

- Check if the character at position1 is uppercase.
(There are probably a few ways to so this. One is using vbscript;
Let>YourLetter={Copy(Phrase,k,1)}
VBEval>Asc("%YourLetter%"),asciiresult
(I thought there was a simple command for this but now can't find it)
Then see if "asciiresult" is between the number for A and Z. (A=65, B=66, etc)

- If it is A-Z, then you either need the next "space" from your position to the end, of if there are no more spaces, you're probably and the end word. Remove appropriate section of text, repeat loop if you're not at the end.
..or
- If not A-Z, add 1, then repeat loop if you're not at the end.


Before you do "continue the loop", make sure k will still be equal or longer than the phrase.

The entire thing could be done with a nice VBScript routine, but that involves getting deeper into vbscript. :]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Mar 25, 2007 1:07 am

Maybe read each line, and use Separate, breaking at the space character.

Then look at the first character of each element.
If ASCII value is lower case, keep and concatenate onto existing elements. If ASCII value is upper case range, skip it, then go to next element.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts