Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default NUM LOCK status

I'm sure I remember reading that this was a know problem in excel 97, but I
don't remember the solution:

I'm building a tool for various users and it's all driven through forms....

however:

when one form closes and another opens the NUM LOCK deselects itself. If I
use sendkeys "{numlock}" it selects it again when I step through the code,
but when I run it, it doesn't work.

I know that numbers can be entered using the number keys above the alpha
keys, but most users use the number pad.

Is there a piece of code that can detect whether NUM LOCK is selected or
not, and reselect it if it isn't?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default NUM LOCK status

See Dave Peterson's post in this thread

http://tinyurl.com/cuocs

Regards,
Peter T


"Black1" wrote in message
...
I'm sure I remember reading that this was a know problem in excel 97, but

I
don't remember the solution:

I'm building a tool for various users and it's all driven through

forms....

however:

when one form closes and another opens the NUM LOCK deselects itself. If I
use sendkeys "{numlock}" it selects it again when I step through the code,
but when I run it, it doesn't work.

I know that numbers can be entered using the number keys above the alpha
keys, but most users use the number pad.

Is there a piece of code that can detect whether NUM LOCK is selected or
not, and reselect it if it isn't?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default NUM LOCK status


Unfortunately I cant get his solution to work, I keep getting

"Can't find DLL entry point getkeyboardstate in user32"

Any (further) suggestions?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default NUM LOCK status

This works for me in Excel 97:


Declare Sub GetKeyboardState Lib "USER32" (lpKeystate As Any)
Declare Sub keybd_event Lib "USER32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2

Sub NTKeyNumlockOn()
Dim lpbKeyState(0 To 255) As Byte
GetKeyboardState lpbKeyState(0)
If lpbKeyState(vbKeyNumlock) = 0 Then
keybd_event vbKeyNumlock, 0, KEYEVENTF_EXTENDEDKEY Or 0, 0
keybd_event vbKeyNumlock, 0, KEYEVENTF_EXTENDEDKEY Or
KEYEVENTF_KEYUP, 0
End If
End Sub

--
Jim
"Black1" wrote in message
...
|
| Unfortunately I cant get his solution to work, I keep getting
|
| "Can't find DLL entry point getkeyboardstate in user32"
|
| Any (further) suggestions?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default NUM LOCK status

Try simply -

Declare Function SetKeyboardState _
Lib "User32" (kbArray As Byte) As Long

Sub NumLocker()

Dim KeyState(0 To 255) As Byte
KeyState(&H90) = 1 ' 1 NumLock on, 0 for off
SetKeyboardState KeyState(0)
End Sub


"Black1" wrote in message
...

Unfortunately I cant get his solution to work, I keep getting

"Can't find DLL entry point getkeyboardstate in user32"

Any (further) suggestions?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I undo the scroll lock, thscroll lock button does not work scroll lock Excel Discussion (Misc queries) 3 July 19th 08 10:17 PM
reuest formula for auto update status & status date PERANISH Excel Worksheet Functions 5 June 2nd 08 04:26 PM
Lock Cell status sunan Excel Discussion (Misc queries) 3 January 24th 06 01:39 AM
Need a msg box that displays time status or loading status havocdragon Excel Programming 2 April 2nd 05 05:29 PM
SENDKEYS change the "Number Lock" status Kenneth Lam Excel Programming 1 May 23rd 04 12:37 PM


All times are GMT +1. The time now is 08:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"