Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Determining if Num Lock is On.

Determining if Num Lock is On

by Allen Wyatt
(last updated May 11, 2016)

3

When you are creating a macro for use in Word, you may want to determine if the Num Lock key is enabled. You can figure out this information by using the Information property with the wdNumLock argument. The technique is shown in the following code:

If Selection.Information(wdNumLock) Then
    Print "The Num Lock key is on"
Else
    Print "The Num Lock key is off"
End If

This, obviously, is not a complete macro. You would use this code within your larger macro, and then adapt it to what you need done depending on whether the NumLock key is enabled or not. The Information property returns either True or False depending on the condition of the key. This makes it very handy for using in the If ... End If construct, as shown.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1204) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Determining if Num Lock is On.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Reusing a Bookmark

Bookmarks in Word are just like bookmarks used in paper books, any given bookmark may be reused to mark a new location. ...

Discover More

Calculating Time Differences between Two Machines

Want to know how much of a time difference there is between your machine and a different machine? This tip provides some ...

Discover More

Comparing Strings

When writing a macro, a common task is the need to compare two strings. You can do this by "normalizing" the strings, as ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (menu)

Controlling the Italic Text Attribute

If you are formatting your document by using a macro, you may need to make some of your text italics. You do that by changing ...

Discover More

Copying a File in VBA

Need to have your macro copy a file from one place to another? It's easy to do using the FileCopy command, described in this ...

Discover More

Checking for a Text Selection Length

Need to know if the user selected some text before running your macro? Here's how to make that check.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 4 + 2?

2017-05-07 15:25:41

GeordieLad

Erik:

My sentiments entirely! When I saw the title of the tip I thought perhaps I'd missed something - or is there something special when creating macros?


2017-05-06 22:48:17

Erik Eilertsen

Er, is my computer unique? It has an illumination on the Num Lock key to tell me if it is on or not....? (I am a bit of a tyro here but...???)


2015-03-27 10:51:41

Greg

Unfortunately, this is not working. Both this statement and also Application.Numlock keep returning TRUE whether the NumLock state is true or false. I even tried the API calls suggested in one of the Microsoft articles. No luck. That also keeps returning TRUE every time. My computer simply cannot reliably determine the state of the key. I'm using Word 2010 in a Windows 7 environment.


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.