#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Focus

I suspect this is possible to do in VBA but I am at a loose end on ho
it is done.

On a userForm that has multiple objects in multiple frames, is i
possible to find out which object at any particular time, irrespectiv
of which frame it is in, has currently got the focus ?

Any ideas?

Thanks in advance

R

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Focus

Hi RM

In theory (this demo click the form surface outside controls to run):

Private Sub UserForm_Click()
MsgBox Me.ActiveControl.Name
End Sub

Problems arise when you use containers, frames and multipages, which I
understand youn will. They will be the active control and you have to dig
for THEIR active control. The approach would be like this

Private Sub UserForm_Click()
On Error Resume Next
MsgBox Me.ActiveControl.Name
MsgBox Me.Controls(Me.ActiveControl.Name).ActiveControl.N ame
End Sub

now you decide how many levels deep are needed and which errors to trap if
there are fewer levels when you search. Problem is probably not that big
when you know what this is for and when it's gonna run.

HTH. Best wishes Harald


"Roy Miller " skrev i melding
...
I suspect this is possible to do in VBA but I am at a loose end on how
it is done.

On a userForm that has multiple objects in multiple frames, is it
possible to find out which object at any particular time, irrespective
of which frame it is in, has currently got the focus ?

Any ideas?

Thanks in advance

R M


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Focus

This looks about right, I will try it out when I get back off holiday.

Roy


---
Message posted from http://www.ExcelForum.com/

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
focus Capp Excel Discussion (Misc queries) 2 November 18th 05 07:25 PM
set focus tkaplan Excel Discussion (Misc queries) 3 September 27th 05 07:41 PM
focus? Chrome[_3_] Excel Programming 3 May 13th 04 10:01 PM
How do I set focus Newbie Excel Programming 2 February 11th 04 07:03 PM
set focus RickK Excel Programming 1 October 10th 03 12:27 PM


All times are GMT +1. The time now is 10:48 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"