Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default How can I check if the ActiveSheet has keyboard focus?

What I'm trying to accomplish is essentially the following:

If ActiveSheet.IsKeyboardFocused = True Then
[Do Something]
End If

Unfortunately, ActiveSheet/Worksheet does not have the IsKeyboardFocused
property (I pulled this property from a Button control as a functional
example).

Is there a way to accomplish this If statement?

Thanks,
Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How can I check if the ActiveSheet has keyboard focus?

hi
the keyboard is just another input device like the mouse. or the bar coded
reader.
how do you determine if the mouse has "focus"?? well...you don't know unitl
a button(key) is pressed then the input device has "focus". if the keyboard
has "focuss" then we may be talking about "keyboard shortcuts" which does
cause code to run i.e. do something. I think that is why we don't seem to
have "isKeyboardFocused" property or a "ismousefocused" property.
having been confused by your post, could you explain further just what your
are trying to accomplish?

regards
FSt1

"Matt" wrote:

What I'm trying to accomplish is essentially the following:

If ActiveSheet.IsKeyboardFocused = True Then
[Do Something]
End If

Unfortunately, ActiveSheet/Worksheet does not have the IsKeyboardFocused
property (I pulled this property from a Button control as a functional
example).

Is there a way to accomplish this If statement?

Thanks,
Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default How can I check if the ActiveSheet has keyboard focus?

Hi and thanks for the reply. I'm less concerned about the keyboard
specifically, and more interested to see if there is a way to check if a
sheet (any sheet) has focus. One thing I thought of is to check the value of
ActiveSheet, however this doesn't always work because ActiveSheet has a value
even when the Options Dialog is open (or any other dialog for that matter).
It also has a value while editing within a cell. Do you know if there is a
way to accomplish the following:

If ActiveSheet.HasFocus = True Then
[Do Something]
End If

Thanks for the help!

Matt

"FSt1" wrote:

hi
the keyboard is just another input device like the mouse. or the bar coded
reader.
how do you determine if the mouse has "focus"?? well...you don't know unitl
a button(key) is pressed then the input device has "focus". if the keyboard
has "focuss" then we may be talking about "keyboard shortcuts" which does
cause code to run i.e. do something. I think that is why we don't seem to
have "isKeyboardFocused" property or a "ismousefocused" property.
having been confused by your post, could you explain further just what your
are trying to accomplish?

regards
FSt1

"Matt" wrote:

What I'm trying to accomplish is essentially the following:

If ActiveSheet.IsKeyboardFocused = True Then
[Do Something]
End If

Unfortunately, ActiveSheet/Worksheet does not have the IsKeyboardFocused
property (I pulled this property from a Button control as a functional
example).

Is there a way to accomplish this If statement?

Thanks,
Matt

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How can I check if the ActiveSheet has keyboard focus?

hi
i think you are trying to make this WAY more complicated that it is.
active = focus.
i can't understand what would be gained by looping through the sheets to see
which one is active. if i need to do something on a certain sheet then...
sheets("sheet1").activate
now sheet 1 has focus. run code.
back to my question. what are you trying to achieve? why are we trying to
find the active sheet? technically the sheet your are looking at on the
screen is the active sheet.
confused here. please help.

regards
FSt1

regards
FSt1




"Matt" wrote:

Hi and thanks for the reply. I'm less concerned about the keyboard
specifically, and more interested to see if there is a way to check if a
sheet (any sheet) has focus. One thing I thought of is to check the value of
ActiveSheet, however this doesn't always work because ActiveSheet has a value
even when the Options Dialog is open (or any other dialog for that matter).
It also has a value while editing within a cell. Do you know if there is a
way to accomplish the following:

If ActiveSheet.HasFocus = True Then
[Do Something]
End If

Thanks for the help!

Matt

"FSt1" wrote:

hi
the keyboard is just another input device like the mouse. or the bar coded
reader.
how do you determine if the mouse has "focus"?? well...you don't know unitl
a button(key) is pressed then the input device has "focus". if the keyboard
has "focuss" then we may be talking about "keyboard shortcuts" which does
cause code to run i.e. do something. I think that is why we don't seem to
have "isKeyboardFocused" property or a "ismousefocused" property.
having been confused by your post, could you explain further just what your
are trying to accomplish?

regards
FSt1

"Matt" wrote:

What I'm trying to accomplish is essentially the following:

If ActiveSheet.IsKeyboardFocused = True Then
[Do Something]
End If

Unfortunately, ActiveSheet/Worksheet does not have the IsKeyboardFocused
property (I pulled this property from a Button control as a functional
example).

Is there a way to accomplish this If statement?

Thanks,
Matt

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default How can I check if the ActiveSheet has keyboard focus?

" if i need to do something on a certain sheet then...
sheets("sheet1").activate"

If I want to do something on that sheet, I'd do something like this

Dim myWS as Excel.worksheet

Set myWS = Worksheets("Sheet1")

myWS.Cells(1,1).value = "enter Value"

Blah blah blah. YOu generally don't need to activate anything to make
changes to any sheet. Besides, doing all that activating and selecting is
slow.
"FSt1" wrote:

hi
i think you are trying to make this WAY more complicated that it is.
active = focus.
i can't understand what would be gained by looping through the sheets to see
which one is active. if i need to do something on a certain sheet then...
sheets("sheet1").activate
now sheet 1 has focus. run code.
back to my question. what are you trying to achieve? why are we trying to
find the active sheet? technically the sheet your are looking at on the
screen is the active sheet.
confused here. please help.

regards
FSt1

regards
FSt1




"Matt" wrote:

Hi and thanks for the reply. I'm less concerned about the keyboard
specifically, and more interested to see if there is a way to check if a
sheet (any sheet) has focus. One thing I thought of is to check the value of
ActiveSheet, however this doesn't always work because ActiveSheet has a value
even when the Options Dialog is open (or any other dialog for that matter).
It also has a value while editing within a cell. Do you know if there is a
way to accomplish the following:

If ActiveSheet.HasFocus = True Then
[Do Something]
End If

Thanks for the help!

Matt

"FSt1" wrote:

hi
the keyboard is just another input device like the mouse. or the bar coded
reader.
how do you determine if the mouse has "focus"?? well...you don't know unitl
a button(key) is pressed then the input device has "focus". if the keyboard
has "focuss" then we may be talking about "keyboard shortcuts" which does
cause code to run i.e. do something. I think that is why we don't seem to
have "isKeyboardFocused" property or a "ismousefocused" property.
having been confused by your post, could you explain further just what your
are trying to accomplish?

regards
FSt1

"Matt" wrote:

What I'm trying to accomplish is essentially the following:

If ActiveSheet.IsKeyboardFocused = True Then
[Do Something]
End If

Unfortunately, ActiveSheet/Worksheet does not have the IsKeyboardFocused
property (I pulled this property from a Button control as a functional
example).

Is there a way to accomplish this If statement?

Thanks,
Matt



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How can I check if the ActiveSheet has keyboard focus?

hi
your are right and i do use that as often as possible. so maybe i wasn't
thinking as clearly as i should have. thank you.
but the point remains.....why are we trying to find the active sheet when
the sheet we are looking at IS then active sheet. and why does it matter
since we can perform actions on other sheets (as you have pointed out).

so the question remains.....
what are you trying to achieve? why are we trying to
find the active sheet? confused. please help.

i am sure there is a reason. educate me.
or maybe i just need to shut up now and let it ride. sigh.

regards
FSt1

"Barb Reinhardt" wrote:

" if i need to do something on a certain sheet then...
sheets("sheet1").activate"

If I want to do something on that sheet, I'd do something like this

Dim myWS as Excel.worksheet

Set myWS = Worksheets("Sheet1")

myWS.Cells(1,1).value = "enter Value"

Blah blah blah. YOu generally don't need to activate anything to make
changes to any sheet. Besides, doing all that activating and selecting is
slow.
"FSt1" wrote:

hi
i think you are trying to make this WAY more complicated that it is.
active = focus.
i can't understand what would be gained by looping through the sheets to see
which one is active. if i need to do something on a certain sheet then...
sheets("sheet1").activate
now sheet 1 has focus. run code.
back to my question. what are you trying to achieve? why are we trying to
find the active sheet? technically the sheet your are looking at on the
screen is the active sheet.
confused here. please help.

regards
FSt1

regards
FSt1




"Matt" wrote:

Hi and thanks for the reply. I'm less concerned about the keyboard
specifically, and more interested to see if there is a way to check if a
sheet (any sheet) has focus. One thing I thought of is to check the value of
ActiveSheet, however this doesn't always work because ActiveSheet has a value
even when the Options Dialog is open (or any other dialog for that matter).
It also has a value while editing within a cell. Do you know if there is a
way to accomplish the following:

If ActiveSheet.HasFocus = True Then
[Do Something]
End If

Thanks for the help!

Matt

"FSt1" wrote:

hi
the keyboard is just another input device like the mouse. or the bar coded
reader.
how do you determine if the mouse has "focus"?? well...you don't know unitl
a button(key) is pressed then the input device has "focus". if the keyboard
has "focuss" then we may be talking about "keyboard shortcuts" which does
cause code to run i.e. do something. I think that is why we don't seem to
have "isKeyboardFocused" property or a "ismousefocused" property.
having been confused by your post, could you explain further just what your
are trying to accomplish?

regards
FSt1

"Matt" wrote:

What I'm trying to accomplish is essentially the following:

If ActiveSheet.IsKeyboardFocused = True Then
[Do Something]
End If

Unfortunately, ActiveSheet/Worksheet does not have the IsKeyboardFocused
property (I pulled this property from a Button control as a functional
example).

Is there a way to accomplish this If statement?

Thanks,
Matt

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change check box name using mouse and keyboard Naum Charts and Charting in Excel 2 December 4th 07 02:36 PM
how can I check for cell focus inside a spreadsheet ? EdwardAlanzo Excel Worksheet Functions 2 May 16th 07 12:41 AM
How do I get the focus on a check box? reneatwork New Users to Excel 1 September 15th 06 02:52 PM
Check for Enter key and change focus? NooK[_40_] Excel Programming 5 August 3rd 04 01:35 PM
Check if activesheet is protected freseh Excel Programming 1 January 30th 04 03:02 PM


All times are GMT +1. The time now is 04:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"