Probably not understanding something simple, but can you lock a toolbar so
that it cannot be resized? I tried the code below but it had no effect. If I
changed .Protection to equal msoBarNoMove, it indeed kept me from moving the
bar, but I just don't want users to be able to resize it.

Thanks!

I tried:
Sub CustomToolbar()
Dim myBar As CommandBar
Dim myCtrl1 As CommandBarControl, myCtrl2 As CommandBarControl
Set myBar = CommandBars.Add(Name:="My Command Bar", Position:=msoBarTop,
Temporary:=True)
With myBar
Set myCtrl1 = .Controls.Add(Type:=msoControlButton,
ID:=CommandBars("Standard").Controls("Print").ID)
Set myCtrl2 = .Controls.Add(Type:=msoControlButton,
ID:=CommandBars("Standard").Controls("Save").ID)
.Visible = True
.Protection = msoBarNoChangeVisible + msoBarNoCustomize +
msoBarNoResize
End With
End Sub

Re: protect toolbar? by Tony

Tony
Wed Dec 14 15:46:52 CST 2005

It works for me.

You don't have any redefinitions of mso contants anywhere do you? Try using
2 instead of msoBarNoResize.

--
Enjoy,
Tony


"Nick B" <NickB@discussions.microsoft.com> wrote in message
news:EB7A6604-5F4A-43C0-8EF8-C7153F96835C@microsoft.com...
> Probably not understanding something simple, but can you lock a toolbar so
> that it cannot be resized? I tried the code below but it had no effect. If
I
> changed .Protection to equal msoBarNoMove, it indeed kept me from moving
the
> bar, but I just don't want users to be able to resize it.
>
> Thanks!
>
> I tried:
> Sub CustomToolbar()
> Dim myBar As CommandBar
> Dim myCtrl1 As CommandBarControl, myCtrl2 As CommandBarControl
> Set myBar = CommandBars.Add(Name:="My Command Bar",
Position:=msoBarTop,
> Temporary:=True)
> With myBar
> Set myCtrl1 = .Controls.Add(Type:=msoControlButton,
> ID:=CommandBars("Standard").Controls("Print").ID)
> Set myCtrl2 = .Controls.Add(Type:=msoControlButton,
> ID:=CommandBars("Standard").Controls("Save").ID)
> .Visible = True
> .Protection = msoBarNoChangeVisible + msoBarNoCustomize +
> msoBarNoResize
> End With
> End Sub