A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi D,
I have not encountered this problem and if, as you suggest, your code should be exculpated, I am unable usefully to speculate on possible alternative causes,
However, perhaps you could use code posted by Rick Rothstein, MVP - Excel at
to turn the NumLock on.
In a standard module, before and outside of any other procedure code, paste:
'==========>>
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
'---------->>
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
'---------->>
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) _
As Long
'---------->>
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo _
As Long)
'---------->>
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) _
As Long
'---------->>
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
'---------->>
Public Sub TurnNumLockOn()
Dim bytKeys(255) As Byte, bnumLockOn As Boolean, typOS As OSVERSIONINFO
GetKeyboardState bytKeys(0)
bnumLockOn = bytKeys(VK_NUMLOCK)
If Not bnumLockOn Then
If typOS.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
bytKeys(VK_NUMLOCK) = 1
SetKeyboardState bytKeys(0)
Else
keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
End If
End If
End Sub
'<<==========
Now, in your code which displays / initiates the Userform, try adding the instruction:
Call TurnNumLockOn
===
Regards,
Norman