PDA

View Full Version : Solved: Disable Close Button on Floating Toolbar



tca_VB
10-01-2008, 11:44 AM
Hopefully this is a small request...

Can you disable the close button on a custom floating toolbar?

What I need is for the custom floating toolbar I created (contains custom button to perform macro) to always be open and the user not to be able to close it.

I would like to keep it floating as it helps the user know where to click when they complete - ie right in front of them regardless where they are on the page.

Thanks - so close...

Oorang
10-07-2008, 08:41 PM
The protection property is the one you want. If you want to use multiple protection constants, just add them.

Option Explicit

Public Sub MakeAnnoyingBar()
Dim cb As Office.CommandBar
Set cb = ThisDocument.CommandBars.Add("DontDoThis", msoBarFloating)
cb.Protection = msoBarNoChangeVisible + msoBarNoCustomize + msoBarNoChangeDock + msoBarNoMove + msoBarNoResize
With cb.Controls.Add(Office.MsoControlType.msoControlButton)
.FaceId = 17
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
.Caption = "Foo"
End With
cb.Visible = True
End Sub

tca_VB
10-13-2008, 06:04 AM
Oorang,
Thanks for the code help.

I added the following to have the button run my macro (fyi for others)

.OnAction = "New_Doc"


Appears to be working great for the template by calling it from Document_Open () to run MakeAnnoyingBar. For some reason, when opening the word doc that references the template, the toolbar is not created. I should be able to solve that part though.

Closing this question as solved. Thanks again!