ty it and seeWould that work?
ty it and seeWould that work?
Not sure I know how all the 0,0,1 bits work though
each key has to be pushed down, then released
like
where 50 is i believe the P keykeybd_event 50, 1, 0, 0 keybd_event 50, 1, KEYEVENTF_KEYUP, 0
Hi,
I have an identical problem. Was using SendKeys until people reported their Numlock turning off. Have been reading this thread and have tried to use Num_Off and Num_On before and after the sendkeys, but Num_On doesn't work. It seems to be ignored and the numlock ends up off when the print job has run.
Did you have any luck with mapping each key stroke to a "keybd_event"?
I must admit that due to other work commitments - I never had the chance to sit down and try and work through this. I am moving on from my job tomorrow so I may not get the opportunity to find out!
Big thanks to Westconn1 though for all his/her help!
Hi,
No probs. Thanks for the reply anyway. I did some further digging around and finally worked out the combination needed. It took a while as a lot of the resources on the net refer to c++ and not VBA.
This is my code, which I put in a new module on it's own.
Here is a helpful article which shows the key mapping [scroll down a bit] http://www.experts-exchange.com/Prog..._24088649.htmlPrivate Declare Sub keybd_event Lib "user32" ( _ByVal bVk As Byte, _ ByVal bScan As Byte, _ ByVal dwFlags As Long, _ ByVal dwExtraInfo As Long) Private Const VK_NUMLOCK = &H90 Private Const KEYEVENTF_KEYUP = &H2 Private Const VK_ALT = &H12 Private Const VK_TAB = &H9 Declare Function GetKeyState Lib "user32.dll" ( _ ByVal nVirtKey As Long) As Integer Sub Print1() keybd_event VK_ALT, 0, 0, 0 'Key press ALT keybd_event 70, 1, 0, 0 'Key press F keybd_event 70, 1, KEYEVENTF_KEYUP, 0 'Key release F keybd_event VK_ALT, 0, KEYEVENTF_KEYUP, 0 'Key release ALT keybd_event 80, 1, 0, 0 'Key press P keybd_event 80, 1, KEYEVENTF_KEYUP, 0 'Key release P keybd_event 82, 1, 0, 0 'Key press R keybd_event 82, 1, KEYEVENTF_KEYUP, 0 'Key release R keybd_event VK_ALT, 0, 0, 0 'Key press ALT keybd_event 83, 1, 0, 0 'Key press S keybd_event 83, 1, KEYEVENTF_KEYUP, 0 'Key release S keybd_event VK_ALT, 0, KEYEVENTF_KEYUP, 0 'Key release ALT keybd_event 49, 1, 0, 0 'Key press 1 keybd_event 49, 1, KEYEVENTF_KEYUP, 0 'Key release 1 keybd_event 13, 1, 0, 0 'Key press ENTER keybd_event 13, 1, KEYEVENTF_KEYUP, 0 'Key release ENTER End Sub
This works for me and my numlock stays on throughout!