Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Can someone SHOW me how to make my macro REPEAT?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim In Minneapolis - 13 Nov 2005 04:28 GMT
Hi!   Can anybody tell me how to make a macro keep REPEATING until it reaches
the end of the list?

Here's my macro . . . it works fine, but it only executes 'once' and then
stops.  I need it to KEEP repeating.  Can anyone please SHOW me how to MODIFY
it so it does what I need?

   Selection.TypeText Text:=""""
   Selection.EndKey Unit:=wdLine
   Selection.TypeText Text:=""""
   Selection.MoveRight Unit:=wdCharacter, Count:=1

What I want to do . . .

I have a column of words (just 1 word on a line) and I need to put QUOTES
around each word

Example:  

    apple
    orange
    banana

     becomes

    "apple"
    "orange"
    "banana"

So we want the macro to go down the entire list of words, and keep
repeating, and then stop when it finally gets to the end.

If anyone can SHOW me how to MODIFY my original macro, I'll sure be grateful!

Thanks again.

Jim
Greg Maxey - 13 Nov 2005 04:50 GMT
Jim,

Select the list and try this:

Sub ScratchMacro()
Dim oPara
Dim oRng As Range
For Each oPara In Selection.Range.Paragraphs
 Set oRng = oPara.Range
 oRng.MoveEnd wdCharacter, -1
 oRng.Text = Chr(34) & oRng.Text & Chr(34)
Next
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi!   Can anybody tell me how to make a macro keep REPEATING until it
> reaches the end of the list?
[quoted text clipped - 34 lines]
>
> Jim
Jim In Minneapolis - 13 Nov 2005 05:11 GMT
THANKS, Greg!

Your're a genius.  Seriously!

You've saved my life.

God bless you.

Jim

> Jim,
>
[quoted text clipped - 48 lines]
> >
> > Jim
Greg Maxey - 13 Nov 2005 17:23 GMT
That is twice this month that someone has made that claim.  Helpful, I try
to be.  A genius, emphatically not.  Glad I could help.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> THANKS, Greg!
>
[quoted text clipped - 58 lines]
>> >
>> > Jim
Tony Jollans - 13 Nov 2005 19:42 GMT
Greg's code is fine but you really don't need a loop, or even code, to do
this.

Assuming your lines are ended with paragraph marks, you can use Find &
Replace ...

Check "Use Wildcards"
Find (<*>)(^13)
Replace "\1"\2
Hit Replace All

You can record code if you want it - and it should be faster than looping
through paragraphs

--
Enjoy,
Tony
> Jim,
>
[quoted text clipped - 54 lines]
> >
> > Jim

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.