L
Larry
I use this code to determine if the cursor is directly to the left of a
real word, rather than directy to the left of a comma or close quote or
some other punctuation which is a "word" according to Word. In other
words, the proof that the cursor is at the start of a real word, and not
at the end of a real word and to the left of a close punctuation, is
that the previous character is a space or an open paren or an open quote
and so on.
Is there a more economical way of achieving the same result, so that I
wouldn't have to have all these conditions checking for the previous
character?
Here's the code:
' If IP is at start of word, move cursor one space right.
Dim prevchar As String
prevchar = Selection.Characters.First.Previous
If (Selection.Start = Selection.Words(1).Start And _
Selection.Characters(1) <> Chr(13) And prevchar = " " Or _
prevchar = "-" Or prevchar = """" Or prevchar = "[" Or _
prevchar = "(" Or prevchar = Chr(151)) Then
x = True
Selection.MoveRight wdCharacter, 1
real word, rather than directy to the left of a comma or close quote or
some other punctuation which is a "word" according to Word. In other
words, the proof that the cursor is at the start of a real word, and not
at the end of a real word and to the left of a close punctuation, is
that the previous character is a space or an open paren or an open quote
and so on.
Is there a more economical way of achieving the same result, so that I
wouldn't have to have all these conditions checking for the previous
character?
Here's the code:
' If IP is at start of word, move cursor one space right.
Dim prevchar As String
prevchar = Selection.Characters.First.Previous
If (Selection.Start = Selection.Words(1).Start And _
Selection.Characters(1) <> Chr(13) And prevchar = " " Or _
prevchar = "-" Or prevchar = """" Or prevchar = "[" Or _
prevchar = "(" Or prevchar = Chr(151)) Then
x = True
Selection.MoveRight wdCharacter, 1