ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   create commandbar / control button using codes (https://www.excelbanter.com/excel-programming/314696-create-commandbar-control-button-using-codes.html)

tango

create commandbar / control button using codes
 
dear frank/all,
i found the below from this forum. its great and almost meet my needs.

1)first time, excel will create the toolbar and button but the next
time when i use the application, error comes out. how to ask excel not
to create as the toolbar and button already created?

2) how to change the smiley button to others using code? if all are
the same user will confuse.

3) how to name/put description to the button using code?

4) i put the following in a button. only authorised user allowed to
use the customised button created from the below. this will not affect
unauthorised personnel, rite? as i put this application in the server.

rgds



Sub create_toolbar()

Dim but1, but2, foundbut As Variant

Set foundbut = Application.CommandBars.FindControl _
(Type:=msoControlCustom, Tag:="Tender Toolbar")

If foundbut Is Nothing Then

Application.CommandBars.Add(Name:="Tender Toolbar").Visible = True

Set but1 = Application.CommandBars("Tender
Toolbar").Controls.Add(Type:=msoControlButton, ID:=2950, _
befo=1)

Set but2 = Application.CommandBars("Tender
Toolbar").Controls.Add(Type:=msoControlButton, ID:=2950, _
befo=2)

but1.OnAction = "Doing action"
but2.OnAction = "Doing action"

End If

End Sub


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com