Control within a frame in Excel
I have an Excel workbook that I want to place a frame on, and within the frame I want to place 4 text boxes and a command button. The problem I am having is that I can not access the command button or text boxes on the frame through any events or code, I can only access the frame. Can anyone offer any advice on how I can access the "click event" for the command button or get the values from the text boxes that are placed on the frame?
Thank you.
Re: Control within a frame in Excel
In a Module place ...
Code:
Public Sub Button1_Click()
MsgBox "Click"
End Sub
Then right click on your button and assign that event to it.
1 Attachment(s)
Re: Control within a frame in Excel
Attachment 60874
I don't have the option to attach an event when I right click on the button. Any other ideas? I attached the file if you want to look at it.
Thanks for your help.
Chrissy
Re: Control within a frame in Excel
right click > view code, this will take you directly to the sub that is called by the button click event
Re: Control within a frame in Excel
The "view code" is grayed out for the button. It shows for the frame (which leads you to the frame click event), but not the button. First I have to select the frame and right click and go to Frame Object > Edit. Then I select the command button and right click. I do not have the option to select "view code" because it is grayed out. Any suggestions?
Re: Control within a frame in Excel
Press Alt+F11. Are you using a Academic, trial, or unactivated version of Excel?
Re: Control within a frame in Excel
That just brings me to the click event for the frame, not the button. The version of Excel I am using is the small business edition 2003. I may have to rethink using the frame unless you have any more ideas?
Thanks for trying to help.
1 Attachment(s)
Re: Control within a frame in Excel
This shouldnt be that difficult. Just right click on the button is design mode and select "Assign Macro" then click the New button and it will write out the event signature for you so all you have to do is write what you want the button to do.
Re: Control within a frame in Excel
i opened the workbook you posted in excel 2000 the view code was available to use for the command button and the textboxes
make sure your controls are in design mode while you do this
1 Attachment(s)
Re: Control within a frame in Excel
Attachment 60886
I know how to assign a macro to a standard control. This is not a standard control placed on the spreadsheet, it is placed on the frame. I think what Robdog888 did above was just draw a frame and then just draw a button over the frame. If you do it like that, the button is not actually attached to the frame... if you move the frame, the button will not move with it. You have go to go into edit mode for the frame and then place the control. It does not then give you the option to assign a macro. It also does not allow me to select "view code" from the button or text boxes, the selection is grayed out. Please see the attachment for screen shots so you can see what I am trying to explain.
Thanks.
Re: Control within a frame in Excel
Even if the controls are grouped you can still access the button click event. How did you create the button in the frame?
Re: Control within a frame in Excel
Select the frame, goto frame object and select edit. Once in edit mode, you right click the frame again and select toolbox. Then the toolbox appears and allows you to draw the objects on the frame. I try double-clicking on the command button so it takes me to the event and nothing happens. I also right click on the button and it does not give me any options other than what is shown on the word doc I posted.
Re: Control within a frame in Excel
That doesnt work for me. I only have an Edit Text in the right click of the frame. Perhaps its because Im using 2007 but it shouldnt be different. Why cant you just group the controls and be done with it?
Re: Control within a frame in Excel
That's because you are using a different frame. I am using the visual basic frame from the controls toolbox and you are using the frame from the forms toolbox.
Re: Control within a frame in Excel
As I stated, 2007 is different. There is no VB Frame in 07.
Still why make things hard? If you group the controls you would be done.
Re: Control within a frame in Excel
I want to be able to hide the control and I don't think you can do that with the form controls.
Re: Control within a frame in Excel
ok, in your example workbook, if in design mode i right click on the frame > frame object > edit
then right click on the command button the view code menu item is disabled
but if i right click directly on the command button the view code option is available, even though the command button is still in the frame
Re: Control within a frame in Excel
It doesn't lead to a click_event for the button though, only the frame.