Testing to see if the cursor is under a letter

J

Joanne

I would like to insert a semi colon after the last letter
of a document. My thought was to move the cursor left
until it is under a letter (there may be other characters
at the end of the document), but I'm not sure how to test
to see if the cursor is under a letter. In WP, there was
a range of ASCII numbers you could test for, but I'm
afraid I don't see that in Word. Thanks for your help in
advance.
 
D

DA

Hi Joanne

To return the ASCII numbers you can use Asc(string).
I'd also suggest you check up on the "Like" function to
do what you want. Here's an example:

------------------
Sub FindLastLetter()
With Selection
.EndKey Unit:=wdStory
While .Text Like "[!A-z]"
.MoveLeft Unit:=wdCharacter, Count:=1
Wend
MsgBox "Last character is " + .Text
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