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?
right click > view code, this will take you directly to the sub that is called by the button click event
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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?
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?
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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.
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.
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?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
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.
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete