XL: Cannot Set Focus for Combination List-edit Box

ID: Q124808


The information in this article applies to:
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a


SYMPTOMS

In the versions of Microsoft Excel listed above, the focus on a dialog box cannot be set to the list component of a combination list-edit box by changing the tab order.


WORKAROUND

If you are using Microsoft Excel for Windows, use the SendKeys command as in the following Visual Basic example.

NOTE: You cannot send keystrokes to applications running under the Macintosh operating system.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
  1. In a dialog sheet that contains a combination list-edit box, click Tab Order on the Tools Menu.


  2. Select the edit box component of the combination list-edit box and use the Move arrows to move the edit box to the top of the tab order.


  3. Select the list box component of the combination list-edit box and use the Move arrows to move the list box to the second position of the tab order.


  4. On a module sheet, enter the following Visual Basic subroutine:
    
          Sub ListFocusExample()
              SendKeys "{tab}"
              Dialogsheets(1).Show
          End Sub 


When the subroutine is executed, the SendKeys command will tab to the list component of the combination list-edit box, giving it the focus immediately after the dialog box is displayed.


MORE INFORMATION

In the versions of Microsoft Excel mentioned above, the focus on a dialog box is determined by the tab order of the elements in the dialog box. The first item in the tab order is designated to have the focus when the dialog box is displayed. When a combination list-edit box is created, it consists of two components: an edit box, which holds the currently selected value and allows user input, and a list box containing a set of possible values from which to choose. If the first item in the tab order is set to the list component of a combination list-edit box, the focus will be set to the next available item in the tab order.


REFERENCES

For more information about using SendKeys, choose the Search button in Visual Basic Help and type:


   sendkeys 

Additional query words: 5.00a 5.00c 7.00a vb vba XL5 XL7

Keywords : kbcode kbprg
Version : WINDOWS:5.0,5.0c,7.0,7.0a; MACINTOSH:5.0,5.0a
Platform : MACINTOSH WINDOWS
Issue type :


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.