Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
In my code I have used various methods to get the focus off of a Control
Toolbox control, like a combo box or check box. One I use is: SendKeys "{ESC}" I don't think that this is the best. But I can't find in all of the code I've written what the other methods I've used are. Don <www.donwiss.com (e-mail link at home page bottom). |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
activesheet.range("a1").select
(choose a cell of your choice?) Don Wiss wrote: In my code I have used various methods to get the focus off of a Control Toolbox control, like a combo box or check box. One I use is: SendKeys "{ESC}" I don't think that this is the best. But I can't find in all of the code I've written what the other methods I've used are. Don <www.donwiss.com (e-mail link at home page bottom). -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
On Thu, 03 Aug 2006, Dave Peterson wrote:
Don Wiss wrote: In my code I have used various methods to get the focus off of a Control Toolbox control, like a combo box or check box. One I use is: SendKeys "{ESC}" I don't think that this is the best. But I can't find in all of the code I've written what the other methods I've used are. activesheet.range("a1").select (choose a cell of your choice?) No. That is the worst way of doing it. You don't know where their cursor is on the sheet and you want to put it back where it was. And you don't want the sheet to move. I had two more I used. One was something about an active window. Don <www.donwiss.com (e-mail link at home page bottom). |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
one possible way ?? '// Worksheet code module Private Sub Worksheet_SelectionChange(ByVal Target As Range) On error resume next Set Rg = Target End Sub '// Std Module Public Rg As Range Sub DoSel() On Error Resume Next Rg.Select End Sub '// called via your controls code @ the End of the controls code eg Checkbox code Private Sub CheckBox1_Click() DoSel End Su -- Ivan F Moal ----------------------------------------------------------------------- Ivan F Moala's Profile: http://www.excelforum.com/member.php...nfo&userid=195 View this thread: http://www.excelforum.com/showthread.php?threadid=56815 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
You should have included more details of what you wanted in your original post.
Don Wiss wrote: On Thu, 03 Aug 2006, Dave Peterson wrote: Don Wiss wrote: In my code I have used various methods to get the focus off of a Control Toolbox control, like a combo box or check box. One I use is: SendKeys "{ESC}" I don't think that this is the best. But I can't find in all of the code I've written what the other methods I've used are. activesheet.range("a1").select (choose a cell of your choice?) No. That is the worst way of doing it. You don't know where their cursor is on the sheet and you want to put it back where it was. And you don't want the sheet to move. I had two more I used. One was something about an active window. Don <www.donwiss.com (e-mail link at home page bottom). -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
ps. maybe something like:
Option Explicit Private Sub ComboBox1_Change() ActiveCell.Activate 'your code here End Sub If you're using a control (like a commandbutton from the control toolbox toolbar), you can change the .takefocusonclick property to false. Dave Peterson wrote: You should have included more details of what you wanted in your original post. Don Wiss wrote: On Thu, 03 Aug 2006, Dave Peterson wrote: Don Wiss wrote: In my code I have used various methods to get the focus off of a Control Toolbox control, like a combo box or check box. One I use is: SendKeys "{ESC}" I don't think that this is the best. But I can't find in all of the code I've written what the other methods I've used are. activesheet.range("a1").select (choose a cell of your choice?) No. That is the worst way of doing it. You don't know where their cursor is on the sheet and you want to put it back where it was. And you don't want the sheet to move. I had two more I used. One was something about an active window. Don <www.donwiss.com (e-mail link at home page bottom). -- Dave Peterson -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
On Fri, 04 Aug 2006, Dave Peterson wrote:
Option Explicit Private Sub ComboBox1_Change() ActiveCell.Activate 'your code here End Sub Yes, that looks like it would work. Thinking about where I have done this before I found this one: Range(ActiveCell.Address).Select Then I think the other I've used was something like: ActiveWindow.Activate I gather any of these are better than sending an escape. If you're using a control (like a commandbutton from the control toolbox toolbar), you can change the .takefocusonclick property to false. (1) I never use a button from the Control toolbox. I see no advantages. (2) I do use ComboBoxes, CheckBoxes, and OptionButtons, usually as I want to be able to hide them. For some reason not all of the Forms controls are hideable. I did not find the .takefocusonclick property on the ComboBox properties list. That is the only control I had a chance to check. Don <www.donwiss.com (e-mail link at home page bottom). |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking focus off control on sheet
Range(ActiveCell.Address).Select
would be redundant compared to ActiveCell.Activate or Selection.Select and if the user had multiple cells selected, would not disturb them as your choice would. CommandButton is the only control that has a takefocusonclick property. -- Regards, Tom Ogilvy "Don Wiss" wrote in message ... On Fri, 04 Aug 2006, Dave Peterson wrote: Option Explicit Private Sub ComboBox1_Change() ActiveCell.Activate 'your code here End Sub Yes, that looks like it would work. Thinking about where I have done this before I found this one: Range(ActiveCell.Address).Select Then I think the other I've used was something like: ActiveWindow.Activate I gather any of these are better than sending an escape. If you're using a control (like a commandbutton from the control toolbox toolbar), you can change the .takefocusonclick property to false. (1) I never use a button from the Control toolbox. I see no advantages. (2) I do use ComboBoxes, CheckBoxes, and OptionButtons, usually as I want to be able to hide them. For some reason not all of the Forms controls are hideable. I did not find the .takefocusonclick property on the ComboBox properties list. That is the only control I had a chance to check. Don <www.donwiss.com (e-mail link at home page bottom). |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Prevent control taking focus when accelerator key is used? | Excel Programming | |||
Prevent control taking focus when accelerator key is used? | Excel Programming | |||
Show userform without it taking focus? | Excel Programming | |||
After checking control checkbox returning focus to the sheet | Excel Programming | |||
Taking focus off a Control Checkbox | Excel Programming |