
Tips.Net > WordTips Home > Macros > VBA Examples > Determining if Caps Lock is On
Summary: If your macro needs to determine the status of the Caps Lock key, you need the code in this tip. Just use the Information property to query the key’s state. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
When you are creating a macro, you may have a need to know if the Caps Lock key is engaged. (For instance, you may want to warn a user to turn the Caps Lock key off.) If you have this need, the following VBA macro code determines the status of the Caps Lock key, and warns you accordingly:
If Selection.Information(wdCapsLock) Then
Print "The Caps Lock key is on"
Else
Print "The Caps Lock key is off"
End If
Tip #733 applies to Microsoft Word versions: 97 2000 2002 2003 2007
More Power! Expand your skills and make Word really sing! It's all possible with macros. The best resource anywhere for macros is WordTips: The Macros. Check it out today!
Discover how to use Word's mail merge tool to create your own custom documents in just minutes. Great e-book answers all your questions. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips