Finding out whether a cap toggle has occurred

L

Larry

Is there a way of knowing if a change ordered by vba has actually
occurred?

For example, I'd like to know, after running the below code, whether the
case of a character was actually changed, since the character might have
been punctuation that doesn't have a case.

If Selection.Words(1).Characters(1).Case = wdUpperCase Then
Selection.Words(1).Characters(1).Case = wdLowerCase
Else
Selection.Words(1).Characters(1).Case = wdUpperCase
End If

Thanks,
Larry
 
J

Jonathan West

Hi Larry

Try this

Dim strChar as String
With Selection.Words(1).Characters(1)
strChar = .Text
If .Case = wdUpperCase Then
.Case = wdLowerCase
Else
.Case = wdUpperCase
End If
If .Text <> strChar Then
MsgBox "Character was modified"
Else
MsgBox "Character was not modified"
End If
End With
 

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