VBA and numlock.

P

Peter Aitken

A client claims that a VBA macro is turning numlock off. I looked in the
docs and see no way for VBA to do this - tell whether numlock is on or off,
yes, but change it, no. Any ideas?
 
J

jbc

Peter,

From help:

NumLock Property

Returns the state of the NUM LOCK key. True if the keys on the numeric key
pad insert numbers, False if the keys move the insertion point. Read-only
Boolean.


NumLock Property Example

This example returns the current state of the NUM LOCK key.

theState = Application.NumLock

Hope this helps.

jbc
 
J

Jay Freedman

A client claims that a VBA macro is turning numlock off. I looked in the
docs and see no way for VBA to do this - tell whether numlock is on or off,
yes, but change it, no. Any ideas?

Hi Peter,

There's nothing built into VBA to do this, but VBA can call Win32 API
functions just like VB can. The function SetNumLockKey at
http://www.devx.com/VB-2-the-Max/Tip/19181/0?trk=MSCP works perfectly
well in VBA.

That said, it's unlikely someone slipped this into your client's
system without their knowledge.
 
P

Peter Aitken

Thanks but please read original message before responding. I *know* how to
tell if numlock is on or off - I need to know if I can change it!!
 
H

Howard Kaikow

Peter Aitken said:
A client claims that a VBA macro is turning numlock off. I looked in the
docs and see no way for VBA to do this - tell whether numlock is on or off,
yes, but change it, no. Any ideas?

Could be that some other software is changing the state.

To determimine whether the cause is your code, I would try the following:

1. Add code to the macro to check the state of NumLock when the macro
starts, and save that state in a variable.
2. Add code to the macro to check the state of NumLock when the macro ends.

If the state has changed, report this and restore the initial state using
the SetNumLockKey API. Of course, you would have to further investigate why
the state is changing.

1st thing to look for is whether your code is using code in libraries that
might cause this.

Another is whether your code is creating. opening, closing docs that might
cause Auto* macro to run, which might use code that causes the problem.

Another cause could be add-ins tat the client has installed and you do not.
For example, when I installed Omni Page Pro Office 14, I found that there is
an AutoClose in that add-in that does something, let's see if I can say this
politely, STUPID!
 

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