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 2005

Tip: Looking for answers? Try searching our database.

Wildcard

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cissy - 08 Mar 2005 22:43 GMT
Greetings:

The following code I have stops when it hits a space. I need it to stop when
it reaches any character (or any digit).  I tried the usual wildcards in the
code to replace the space with no luck.  

With Selection
   .HomeKey Unit:=wdStory
   With .Find
       .ClearFormatting
       .Text = "^m"
       .Forward = True
       .Wrap = wdFindStop
       Do While .Execute
           With Selection
               .MoveRight
               .MoveEndUntil Cset:=" " 'right here is my problem
               .Delete
           End With
       Loop
   End With

Any ideas for a wildcard?  Thank you
Klaus Linke - 09 Mar 2005 02:55 GMT
Hi Cissy,

With "Match wildcards", ^m will find both page breaks and section breaks. So it'll get ugly if you just want to match page breaks.

You could build the string for Cset in the macro:

Dim i
Dim str As String
str = ""
For i = AscW("a") To AscW("z")
   str = str & ChrW(i)
Next i
For i = AscW("A") To AscW("Z")
   str = str & ChrW(i)
Next i
For i = AscW("0") To AscW("9")
   str = str & ChrW(i)
Next i
' ...
   .MoveEndUntil Cset:=str

You'd miss accented characters, though...
Might it be easier to specify the characters you want to delete (.MoveEndWhile)?

Greetings,
Klaus

> Greetings:
>
[quoted text clipped - 19 lines]
>
> Any ideas for a wildcard?  Thank you
Cissy - 09 Mar 2005 16:33 GMT
Thanks Klaus:

Actually, all I want to do is go to the top of each page in teh entire
document, and delete the hard returns at the top of each page - that's it!  
Am I making this too hard?  Is there another way?  Thanks again

> Hi Cissy,
>
[quoted text clipped - 46 lines]
> >
> > Any ideas for a wildcard?  Thank you
Klaus Linke - 10 Mar 2005 13:23 GMT
Hi Cissy,

If you just want to remove hard returns, line breaks and white space, you could use

      .MoveEndWhile Cset:=Chr(13) & Chr(11) & Chr(32) & Chr(9) & Chr(160)

(13==B6-mark, 11=line break, 32=space, 9=tab, 160=non-breaking space)

Regards,
Klaus

> Thanks Klaus:
>
[quoted text clipped - 53 lines]
> > >
> > > Any ideas for a wildcard?  Thank you
Cissy - 09 Mar 2005 16:49 GMT
Correction to my last message, I need to delete from the top of each page
until it finds either a space or character.  So, it will remove the junk and
paragraph returns.  I'm tryign really hard to learn this, thanks for your
help1

> Hi Cissy,
>
[quoted text clipped - 46 lines]
> >
> > Any ideas for a wildcard?  Thank you

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.