Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lisa Anderson   on Feb 24 In MS Office Category.

  
Question Answered By: Abriana Rossi   on Feb 24

The Help files in the VB Script editor on XL 2002 have an entry for
set focus: (copy / paste below).

SetFocus Method
See Also Applies To Example Specifics
Moves the keyboard focus  to the specified command bar control. If the
control is disabled or isn't visible, this method  will fail.

Remarks
The focus on the control is subtle. After you use this method, you
will notice a three dimensional highlight on the control. Pressing the
arrow keys will navigate in the toolbars, as if you had arrived at the
control by pressing only keyboard controls.

expression.SetFocus

expression Required. An expression that returns a CommandBarControl,
CommandBarButton, CommandBarPopup, or CommandBarComboBox object.

Example
This example creates a command bar named "Custom" and adds a ComboBox
control and a Button control to it. The example then uses the SetFocus
method to set  the focus to the ComboBox control.

Set focusBar = CommandBars.Add(Name:="Custom")
With CommandBars("Custom")
.Visible = True
.Position = msoBarTop
End With

Set testComboBox = CommandBars("Custom").Controls _
.Add(Type:=msoControlComboBox, ID:=1)
With testComboBox
.AddItem "First Item", 1
.AddItem "Second Item", 2
End With
Set testButton = CommandBars("Custom").Controls _
.Add(Type:=msoControlButton)
testButton.FaceId = 17
' Set the focus to the combo  box.
testComboBox.SetFocus

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on SetFocus Error Or get search suggestion and latest updates.


Tagged: