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 / March 2007

Tip: Looking for answers? Try searching our database.

Help with word macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
somebody@somewhere.com - 25 Mar 2007 17:09 GMT
After getting totally frustrated and not being able to find the
solution for a word macro I am trying to write, I'm back to try again.
Some of you might remember my earlier posts and I want to thank those
of you who tried to help but none of the code accomplished what I was
trying to do. I will try and explain, as best I can, what I am trying
to do. Below is a macro I recorded in Word 2007, which is the version
I am now using, that does the basic thing but I need a little, or
maybe a lot more. Please remember that I am a beginner with only a
basic understanding of writing macros so please explain any replys if
it contains code for me to try.

Sub Macro1()
'
' Macro1 Macro
'
'
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
       .Text = "G"
       .Replacement.Text = " "
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
End Sub

As you can see, this is simply a find and replace macro. Here is what
I need the help with. I need the code to do the following:

Move the cursor to the beginning of the document so that it searches
the entire document without me telling it to return to the beginning
and continue the search.

Be able to adjust the macro to search for multiple letters, numbers or
symbols in the same procedure. In my macro above I searched for the
letter "G" and replaced it with a blank space. I would like to be able
to adjust the macro code to find and replace any number of characters.
like "G" and "Y" just by adjusting the code.

Finally, after the search and replace has finished I would like for
the macro or another sub routine to remove all blank spaces between
all remaining characters left in the document. The exception being
that it will leave two blank spaces after any puncuation marks,
keeping the sentences seperated.

Maybe I am asking for too much, and if so, I appoligize. This has
frustated me for over two years now. Because of this I plan on, after
retireing this summer, attending school to learn how to do what I am
asking now. Thanks to all.  Joe Payne
Greg Maxey - 25 Mar 2007 18:22 GMT
Joe,

> Finally, after the search and replace has finished I would like for
> the macro or another sub routine to remove all blank spaces between
> all remaining characters left in the document. The exception being
> that it will leave two blank spaces after any puncuation marks,
> keeping the sentences seperated.

Before going to any real effort here, can you explain what kind of sentences
you plan to have if you don't have any spaces between the words?

Signature

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

> After getting totally frustrated and not being able to find the
> solution for a word macro I am trying to write, I'm back to try again.
[quoted text clipped - 52 lines]
> retireing this summer, attending school to learn how to do what I am
> asking now. Thanks to all.  Joe Payne
Doug Robbins - Word MVP - 25 Mar 2007 22:00 GMT
And please do not post the same question separately to multiple newsgroups.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> After getting totally frustrated and not being able to find the
> solution for a word macro I am trying to write, I'm back to try again.
[quoted text clipped - 52 lines]
> retireing this summer, attending school to learn how to do what I am
> asking now. Thanks to all.  Joe Payne
 
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.