Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ActiveControl returns "wrong" value if ctrl is on a multipage ctrl
I have a userform that contains a multipage control. Each of the pages of this control has several other controls on it. I'm adding a help key functionality to my form that pops up a help message whenever the user hits the F1 key while a control has the focus. The code I was implementing to do this is: Call HelpMsg(Me.ActiveControl.Name) Unfortunately, if the control with the focus is on one of these multipage controls, Me.ActiveControl.Name returns then name of the multi-page control, not the text, list, or combo that is on that control. I can obviously hard code the name of the control as the parameter, but it is easier to copy and paste the same code over and over again. Is there another techique that will provide the name of the control that actually has the focus? Dale -- Email address is not valid. Please reply to newsgroup only. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ActiveControl returns "wrong" value if ctrl is on a multipage ctrl
Dale,
You need the active control on the active page... Me.MultiPage1.SelectedItem.ActiveControl -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "Dale Fye" wrote in message I have a userform that contains a multipage control. Each of the pages of this control has several other controls on it. I'm adding a help key functionality to my form that pops up a help message whenever the user hits the F1 key while a control has the focus. The code I was implementing to do this is: Call HelpMsg(Me.ActiveControl.Name) Unfortunately, if the control with the focus is on one of these multipage controls, Me.ActiveControl.Name returns then name of the multi-page control, not the text, list, or combo that is on that control. I can obviously hard code the name of the control as the parameter, but it is easier to copy and paste the same code over and over again. Is there another techique that will provide the name of the control that actually has the focus? Dale -- Email address is not valid. Please reply to newsgroup only. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
ActiveControl returns "wrong" value if ctrl is on a multipage ctrl
Hi,
Modify your routine to accept an object rather than text and then test that object for type. If it's one of the container types re call the routine with the activecontrol of the container. Sub HelpMsg(Ctl As Object) If TypeOf Ctl Is MultiPage Then HelpMsg Ctl.Pages(Ctl.Value).ActiveControl ElseIf TypeOf Ctl Is Frame Then HelpMsg Ctl.ActiveControl Else MsgBox Ctl.Name End If End Sub The actual call to the routine will also require changing. Call HelpMsg(ActiveControl) Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info "Dale Fye" wrote in message ... I have a userform that contains a multipage control. Each of the pages of this control has several other controls on it. I'm adding a help key functionality to my form that pops up a help message whenever the user hits the F1 key while a control has the focus. The code I was implementing to do this is: Call HelpMsg(Me.ActiveControl.Name) Unfortunately, if the control with the focus is on one of these multipage controls, Me.ActiveControl.Name returns then name of the multi-page control, not the text, list, or combo that is on that control. I can obviously hard code the name of the control as the parameter, but it is easier to copy and paste the same code over and over again. Is there another techique that will provide the name of the control that actually has the focus? Dale -- Email address is not valid. Please reply to newsgroup only. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
ActiveControl returns "wrong" value if ctrl is on a multipage
Andy,
Very elegant. Thanks. -- Email address is not valid. Please reply to newsgroup only. "Andy Pope" wrote: Hi, Modify your routine to accept an object rather than text and then test that object for type. If it's one of the container types re call the routine with the activecontrol of the container. Sub HelpMsg(Ctl As Object) If TypeOf Ctl Is MultiPage Then HelpMsg Ctl.Pages(Ctl.Value).ActiveControl ElseIf TypeOf Ctl Is Frame Then HelpMsg Ctl.ActiveControl Else MsgBox Ctl.Name End If End Sub The actual call to the routine will also require changing. Call HelpMsg(ActiveControl) Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info "Dale Fye" wrote in message ... I have a userform that contains a multipage control. Each of the pages of this control has several other controls on it. I'm adding a help key functionality to my form that pops up a help message whenever the user hits the F1 key while a control has the focus. The code I was implementing to do this is: Call HelpMsg(Me.ActiveControl.Name) Unfortunately, if the control with the focus is on one of these multipage controls, Me.ActiveControl.Name returns then name of the multi-page control, not the text, list, or combo that is on that control. I can obviously hard code the name of the control as the parameter, but it is easier to copy and paste the same code over and over again. Is there another techique that will provide the name of the control that actually has the focus? Dale -- Email address is not valid. Please reply to newsgroup only. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a difference between CTRL+D and CTRL+" (quotation marks) | Excel Discussion (Misc queries) | |||
How to Double click a blank cell to enact "ctrl + ;" | Excel Worksheet Functions | |||
2007 - Column unhide in Excel does not work i.e. "Ctrl+shift+)" | Excel Discussion (Misc queries) | |||
Can I have "Shift-Click" or "Ctrl-Click" Code on Form List? | Excel Programming | |||
VBA code to display the "Find" (Ctrl+F) dialog box | Excel Programming |