Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replacement for INKEY$
I am collecting EEG data from a patient using a VBA macro reading the data from
a A/D device. Normally it takes data for an hour. However, if the duration is cut short, I want to have the operator hit ESC or the Space Bar and have the program (macro) detect that a key stroke was hit so I can then save the file, as is normally done at the end of the session. In the old days (DOS) I used K$=INKEY$ and then checked K$ for the charcter number of the key. However, that statement does not work anymore. Any idea how to do this would be much appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replacement for INKEY$
Try this: Put the code at the bottom in the ThisWorkbook object of your
VBA workbook. Then, in the macro that you've programmed, put in an if statement that says: If blnStop < True Then <do whatever it was doing Else Exit Sub End If Please let me know if you have problems with this. Mark Dim blnStop As Boolean Private Sub Workbook_Open() blnStop = False Application.OnKey "{ESC}", "StopMacro" End Sub Sub StopMacro() blnStop = False End Sub --- Mark Bigelow mjbigelow at hotmail dot com http://hm.imperialoiltx.com *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replacement for INKEY$
Look in Excel VBA help for EnableCancelKey
Regards, Tom Ogilvy JackHouck wrote in message ... I am collecting EEG data from a patient using a VBA macro reading the data from a A/D device. Normally it takes data for an hour. However, if the duration is cut short, I want to have the operator hit ESC or the Space Bar and have the program (macro) detect that a key stroke was hit so I can then save the file, as is normally done at the end of the session. In the old days (DOS) I used K$=INKEY$ and then checked K$ for the charcter number of the key. However, that statement does not work anymore. Any idea how to do this would be much appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Value Replacement | Excel Worksheet Functions | |||
number replacement | Excel Discussion (Misc queries) | |||
#N/A Replacement | Excel Discussion (Misc queries) | |||
Replacement | Excel Discussion (Misc queries) | |||
Binder replacement for XP | Excel Discussion (Misc queries) |