Microsoft KB Archive/191111

From BetaArchive Wiki

Article ID: 191111

Article Last Modified on 6/17/2005



APPLIES TO

  • Microsoft Excel 98 for Macintosh



This article was previously published under Q191111


SUMMARY

In Microsoft Excel 98 Macintosh Edition, to disable all the keys on the keyboard, set the Microsoft Visual Basic for Applications DataEntryMode property or use the Microsoft Excel 4.0 macro ENTER.DATA() function.

Note that you can also disable keys on the keyboard with the ON.KEY() function, but this function will not allow you to disable keys such as the SPACEBAR or the PLUS SIGN (+).

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Sample Visual Basic Procedure

This code turns off keyboard entry for the active sheet only. To turn keyboard entry back on, press CTRL+D.

   ' Macro to turn off keyboard entry.
   Sub KeyboardOff()
      ' Sets CTRL+D to activate KeyboardOn.
      Application.OnKey "^d", "KeyboardOn"
      Application.DataEntryMode = True
   End Sub
   ' Macro to restore keyboard entry.
   Sub KeyboardOn()
      Application.DataEntryMode = False
   End Sub
                

Excel 4.0 Macro Example

The following macro example turns on Data Entry mode. The keystroke CTRL+D initiates the second macro which turns Data Entry mode off. The macro assumes that all cells on the worksheet are locked.

   A1: =ON.KEY("^d","DataEntryOff")
   A2: =ENTER.DATA(2)
   A3: =RETURN()
   A4:
   A5: DataEntryOff
   A6: =ENTER.DATA(FALSE)
   A7: =RETURN()
                

The function ENTER.DATA() turns on Data Entry mode and allows you to enter data into unlocked cells. This function does not allow you to enter data into locked cells on the worksheet.

NOTE: You can turn off Data Entry mode by pressing the ESC key. If you use the number 2 for the logical argument, you will not be able to turn off Data Entry mode with the ESC key.

REFERENCES

For more information about the OnKey method, from the Visual Basic Editor, click the Office Assistant, type onkey, click Search, and then click to view "OnKey Method."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

176476 OFF: Office Assistant Not Answering Visual Basic Questions



Additional query words: XL98

Keywords: kbhowto KB191111