C
cyraxote
I am trying to write a macro to search through a reference list, find
the titles, and make each word (after the first) lower case, UNLESS
(1) the word is already lower case or (2) both the first and the
second letters are upper case, indicating an acronym.
I can find the titles with no problem, but testing each word is really
stumping me. Below is the latest version of this code:
For wd = 1 To Selection.Words.Count
MyWord = Selection.Words(wd)
If MyWord.Characters(1) = wdUpperCase Then
L1 = True
Else
L1 = False
End If
If MyWord.Characters(2) = wdUpperCase Then
L2 = True
Else
L2 = False
End If
If L1 = True And L2 = False Then
MyWord.Case = wdLowerCase
End If
Next wd
The problem is that word just gives up execution on the line "If
MyWord.Characters(1) = wdUpperCase Then"--as I step through, the
yellow highlight disappears at this line, and a blinking cursor
appears in the margin. Stepping to the next line moves the yellow
highlight back to the beginning of the macro.
Now, I'm pretty sure that I'm mixing my object methods and/or
properties here in some way. I have a fairly good grasp of the
Selection object, but the Range object is like a foreign country.
Any help would be greatly appreciated.
Thanks.
Rodney
the titles, and make each word (after the first) lower case, UNLESS
(1) the word is already lower case or (2) both the first and the
second letters are upper case, indicating an acronym.
I can find the titles with no problem, but testing each word is really
stumping me. Below is the latest version of this code:
For wd = 1 To Selection.Words.Count
MyWord = Selection.Words(wd)
If MyWord.Characters(1) = wdUpperCase Then
L1 = True
Else
L1 = False
End If
If MyWord.Characters(2) = wdUpperCase Then
L2 = True
Else
L2 = False
End If
If L1 = True And L2 = False Then
MyWord.Case = wdLowerCase
End If
Next wd
The problem is that word just gives up execution on the line "If
MyWord.Characters(1) = wdUpperCase Then"--as I step through, the
yellow highlight disappears at this line, and a blinking cursor
appears in the margin. Stepping to the next line moves the yellow
highlight back to the beginning of the macro.
Now, I'm pretty sure that I'm mixing my object methods and/or
properties here in some way. I have a fairly good grasp of the
Selection object, but the Range object is like a foreign country.
Any help would be greatly appreciated.
Thanks.
Rodney