Highlighting characters.

J

Joanne

I would like the cursor to move left and highlight any
text as long as that text is not a letter. For instance,
if there's a space or a semi colon, I want them to be
highlighted. I am going to delete all highlighted text.
However, when I run the following code, it only highlights
two characters and then stops. Any help would be
appreciated.


While .Text Like "[!A-z]"
.MoveLeft Unit:=wdCharacter, Extend:=wdExtend
Wend
 
H

Helmut Weber

Hi Joanne:
how about this one:
Sub Test555()
Dim iResult As Integer
iResult = "aa" Like "[A-z]"
MsgBox CBool(iResult)
iResult = "a" Like "[A-z]"
MsgBox CBool(iResult)
'---
With Selection
While .Range.Previous Like "[!A-z]"
.MoveLeft _
Unit:=wdCharacter, _
Extend:=wdExtend
Wend
.Range.HighlightColorIndex = wdYellow
End With
End Sub
 

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