Disable Floating CommandBar Close Button

G

geoff

Hi
Tried another group but with no luck at all.

Is it possible to disable the close button on a custom
floating commandbar as with the close button on a form
using UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)?

If so, how?

Creating the bar:

Set floatbar = CommandBars.Add("Anything ",
Position:=msoBarFloating)

....gives the bar type but I have no idea how to get the
close button or what to do with it. :):)



I'd be very grateful for any advice.

Geoff
 
C

Cindy M -WordMVP-

Hi Geoff,
Is it possible to disable the close button on a custom
floating commandbar as with the close button on a form
using UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)?
Certainly not in the Office object model. It might be
possible using the Windows API, but I'm only guessing this
mght be the case.

If all you want to do is prevent the user closing it, making
changes, etc. check out the Protection property of the
CommandBar object.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun
8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
G

Geoff

Hi Cindy
Thanks for the reply. Strange, I played around with the
protection at your suggestion to see if I could prevent
customization, resizing etc but to no avail. They
compile ok, I'm addressing the right object - though
after a while you begin to doubt right and left but
nothing has any effect. Wondering now if there is some
exclusion on floating bars?
Going back to the original, it seems a little dangerous
in usage not to be able to disable the close button on
such small objects - the dimensions on mine are 1 button
wide by 4 deep. This makes the customize button very
adjacent to the close button. I've had to protect
against loss, either by accident or curiosity, by using
an activation event on a second sheet to restore it -
hardly an elegant solution.
I'll just have to persevere with the search for a
solution and head off in the way of APIs I guess.

Geoff
 
G

Geoff

Hi Cindy
Further testing reveals that seemingly only one
protection property can be set with msobarNo.... however
the following combination works in XL2002:
Sub testbar()

Dim cb As CommandBar

On Error Resume Next
Application.CommandBars("test").Delete
On Error GoTo 0

Set cb = Application.CommandBars.Add(Name:="test",_
temporary:=True)
With cb
.Visible = True
.Protection = msoBarNoChangeVisible
End With

Application.CommandBars.DisableCustomize = True

End Sub

This removes the close button as you suggested and is
specific to the custom bar. The last line disbles
customisation on all bars, and is NOT specific.
It also means you have to reset when you finish like so:

Sub reset()
Application.CommandBars.DisableCustomize = False
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

Top