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 / February 2005

Tip: Looking for answers? Try searching our database.

Searching for spaces

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joanne - 28 Feb 2005 20:59 GMT
Hello, I wrote the following code to replace any instance of a semi colon and
one or more spaces following, but it doesn't seem to do anything.  No errors,
just no result.  Any ideas why this doesn't work?

Thanks very much for any help you can provide.

Sub GetSemis()
Set rng = ActiveDocument.Range
With rng.Find
.ClearFormatting        
.Forward = True
       .Wrap = wdFindContinue
     
       .Text = (";& Chr(32){1,}")
   With .Replacement
       .ClearFormatting
       .Text = "Hello"
   End With
       .Execute Replace:=wdReplaceAll
End With

End Sub
Dave Lett - 28 Feb 2005 21:09 GMT
Hi Joanne,

You have your search string wrong. It's actually looking for the ampersand,
a space, Chr(32). You also haven't specifically started a wildcard search.
Try the following instead:

With Selection.Find
   .ClearFormatting
   .Text = "; {1,}"
   With .Replacement
       .ClearFormatting
       .Text = "Hello"
   End With
   .MatchWildcards = True
   .Forward = True
   .Wrap = wdFindContinue
   .Execute Replace:=wdReplaceAll
End With

HTH,
Dave

> Hello, I wrote the following code to replace any instance of a semi colon and
> one or more spaces following, but it doesn't seem to do anything.  No errors,
[quoted text clipped - 18 lines]
>
> End Sub
Joanne - 28 Feb 2005 21:23 GMT
Thank you, it worked!

> Hi Joanne,
>
[quoted text clipped - 42 lines]
> >
> > End Sub
 
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.