custom toolbar options

ishi

Board Regular
Joined
Apr 3, 2003
Messages
126
I have created my own toolbar and just placed it at the top. What i would like to do is have this hidden or disabled on open of workbook. Also i have a login form that loads on open of the workbook and when the users enter their logins (not set up yet) depening who they are can have certain buttons enabled on my toolbar. After the login process have the toolbar unhidden.

Any help much appreciated.

Thanks,

ishi
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Pretty simple to do. You will just need info as to what controls are going to be locked for which users, then you can loop thru that and enable/disable controls.

Hiding/Unhiding the toolbar is pretty easy too. Assuming that your toolbar is named "CustomBar"...
Code:
Application.CommandBars("CustomBar").Visible = True 'Show
Application.CommandBars("CustomBar").Visible = False 'Hide
 
Upvote 0
Thanks TommyGun for that. Just one thing i am not entirely sure on looping through the controls on my toolbar.

I have tried this
For i = 1 To Application.CommandBars("CustomBar").Controls.Count
MsgBox s.Name
Next i

But keeping getting error "object or with block variable not set."

any ideas what's wrong.

Thanks,

ishi
 
Upvote 0
What's your variable s?

Try:

Code:
Dim Ctrl As CommandBarControl
For Each Ctrl In Application.CommandBars("CustomBar").Controls
MsgBox Ctrl.Name 
Next Ctrl
 
Upvote 0
my variable was dim s as control. Which probably isn't right but with your example i get run-time error 438 object doesn't support the property or method.

ishi
 
Upvote 0
Instead of
Code:
Ctrl.Name
use
Code:
Ctrl.Caption

CommandBarControls do not have a NAME property, they are referred to by their CAPTION.
 
Upvote 0
thanks that works. But i am surprised that the caption is the name that i have given to the buttons on my toolbar. A little confusing.

ishi
 
Upvote 0
Nobody said this would be easy. :devilish:

ME said:
Pretty simple to do.

Actually, if you want to talk about confusing Object models, then try to code some things in Word. :oops:
 
Upvote 0

Forum statistics

Threads
1,213,485
Messages
6,113,931
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top