Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
#1. There are two different types of buttons you can use on a worksheet.
The first is from the control toolbox toolbar. You just double click on it and put your code within that sub. The second is from the Forms toolbar. You put your code in a General module. Then add the button. When you've added it, you'll be prompted to assign the macro to the button. (You can right click on it later and then assign the macro if you weren't ready.) #2. If you protect the worksheet, then the buttons will be safe. #3. Inside the VBE, you can protect your project. Select your project and then Tools|VBAProject Properties|Protection Tab Give it a memorable password and check that box to lock from viewing. #4. From the Control toolbox toolbar: Option Explicit Private Sub CommandButton1_Click() MsgBox "HI" Me.CommandButton1.Visible = False 'or Me.CommandButton1.Enabled = False End Sub You could hide it or disable it. (and show it later/enable it later). From the Forms toolbar: Option Explicit Sub testme01() MsgBox "Yo" With ActiveSheet.Buttons(Application.Caller) .Enabled = True 'or .Visible = False End With End Sub "RichardO <" wrote: Hello all: I am just learning how to use vba in excel. I have a code that I would like to 1) assign to a command button, how do I do this? 2) I also don't want users to be able to move or delete the command button, how do I do this. 3) Can I protect the code in the command button so that users can't change the code? 4) Also, is it possible for me to disable the button once it has been clicked once, so that users don't keep on running the code once it's been executed once? Thanks much for all your help. Richardo. --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do you assign a macro to a command button in Excel 2003 | Excel Discussion (Misc queries) | |||
Assign a macro to a command button | Excel Discussion (Misc queries) | |||
Assign a macro to Command Button Object | Excel Discussion (Misc queries) | |||
How do I assign a macro I have created to a Command Button in Exc. | Excel Discussion (Misc queries) | |||
Assign Macro to Command Button | Excel Programming |