how to create toolbar?

  • Thread starter Thread starter tango
  • Start date Start date
T

tango

dear frank/all,
1) username is the one input when doing the installation? the
application is sitting in server and shared by about 20 users.
2) may i know how to have the proper coding for the below? especially
the create toolbar. i really have no idea.

thanks alot





hi
have to tried using the Application.username to qualify
the ones who are authorized?
something like this in the open event
if application.username = "somebody" the
create toolbar
end if

regards
Frank
 
This is just a modification of the "Collection of Buttons" example on my web
site.

Ideally you would move the "Case "Rob van Gelder": blnAllowed = True" logic
as, say, a range lookup or similar. It's not a great idea to leave dynamic
data (such as access control lists) in code modules.



Const cCommandBar = "MyCommandBar"

Sub Toolbar_ON()
Dim blnAllowed As Boolean, bar As CommandBar

For Each bar In Application.CommandBars
If bar.Name = cCommandBar Then bar.Delete
Next

Select Case Application.UserName
Case "Rob van Gelder": blnAllowed = True
Case Else: blnAllowed = False
End Select

If blnAllowed Then
Set bar = Application.CommandBars.Add(Name:=cCommandBar,
Position:=msoBarTop, Temporary:=True)

With bar.Controls.Add(Type:=msoControlButton)
.FaceId = 136
.Caption = "Click Me"
.TooltipText = "Click here for a Message Box"
.Style = msoButtonIconAndCaption
.OnAction = "Button_Click"
End With

bar.Visible = True
End If
End Sub

Sub Button_Click()
MsgBox "You clicked the button!"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top