PDA

View Full Version : Solved: I have a Frame1 on Sheet1.



Erdin? E. Ka
10-13-2006, 10:27 AM
Hi everyone,:hi:

I have a Frame1 ( Control ToolBox | More Controls | Microsoft Form 2.0 Frame) on Sheet1.

I was added a CommandButton1 ( Control ToolBox | More Controls | Microsoft Form 2.0 CommandButton) on Frame1 but CommandButton1 is not visible if i click to Exit Design Mode.

I can not understand the problem. :dunno

Thanks in advance.

mvidas
10-13-2006, 11:19 AM
Erdin?,

Working with Frames on a worksheet gets a little tricky, it has a specific order things need to be done in.
Step by step:
1) Add the frame
2) Right-click the frame, go to Frame Object, then Edit
3) A new toolbox toolbar is opened (caption is "Toolbox" and not "Control Toolbox" this time, though the control toolbox is probably still there)
4) Using this new Toolbox, select the command button there. Add it to the frame.
This does not work the same as normal command buttons. :( It is still possible to control the events for it, though it isn't as simple.
In the sheet object your frame is in, put the following at the very top:
Public WithEvents CB3 As MSForms.CommandButton
Then in your workbook_open code (or code that you know will be run before the user gets a chance to click that button), add the following line:
Set Sheets("Sheet1").CB3 = Sheets("Sheet1").Frame1.Controls("CommandButton1")Change the commandbutton1 name as needed.
After you entered that WithEvents line in your sheet object, you'll have noticed that CB3 is now an option in your first drop down box there. So you can have something like this in your sheet object's code:

Private Sub CB3_Click()
MsgBox "commandbuton t?kland?"
End Sub

As I said, not exactly easy, but possible. Personally I'd say don't bother with it, and just use a normal command button or a userform, but it is up to you.

I'm attaching the sample file back again, updated.

Erdin? E. Ka
10-13-2006, 02:44 PM
Hi mvidas,:hi:

Thank you very much to kindly help and suggest. :friends:

I aggre your suggestion. :yes UserForm is best object.

Thanks a lot. :thumb