Wildcard

C

Cissy

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
 
K

Klaus Linke

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
 
C

Cissy

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
 
C

Cissy

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
 
K

Klaus Linke

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=¶-mark, 11=line break, 32=space, 9=tab, 160=non-breaking space)

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top