
Tips.Net > ExcelTips Home > Macros > VBA Examples > Determining if Caps Lock is On
Summary: If you have a macro that requests user input, you may want to make sure that the user doesn’t make entries if the Caps Lock key is engaged. This tip explains how you can check the condition of the key so that you can make decisions in your macro. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 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 #2469 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
PivotTables Got You Perplexed? PivotTables for the Faint of Heart shows how you can start using Excel's PivotTable tool right away to spin your data into gold! You discover how easy it really is to crunch the numbers you need to crunch. Uncover the power of creating PivotTables, editing them, formatting them, customizing them, and much more.
Check out PivotTables for the Faint of Heart today!
You can put times into a worksheet, but then what? Need to do calculations with times? How about working with elapsed time? Don't be confused; learn how easy it can be. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips
Advertise on the
ExcelTips Site