Creating Custom Toolbars

E

excel_naive

Hello,
Can anyone help me in understanding how to create a custo
toolbar to have my own format???I have taken some help from an exce
text book and created this code below....But I am not happy with th
way its working cos its not doing what I am loking for....

I am trying to add either another control/button to the buil
in list in the Category Menu of the formatcells toolbar
For eg:
we have built in categories like General,Number,Accounting etc et
....Can I add my own button to this list or...can add my own format t
the list in custom format??:confused: Herz what I have....An
revisions/modifications to this code to make it work the way I wan
greatly appreciated.....
Sub MakeCustomFormatDisplay()
Dim Tbar As CommandBar
Dim NewBtn As CommandBarButton
On Error Resume Next
CommandBars("Custom Format").Delete
On Error GoTo 0

Set Tbar = CommandBars.Add
With Tbar
.Name = "Custom Format"
.Visible = True
End With
Set NewBtn = CommandBars("Custo
Format").Controls.Add(Type:=msoControlButton)
With NewBtn
.Caption = " "
.OnAction = "FormatChanger"
.TooltipText = "Click to change the Custom format"
.Style = msoButtonCaption
End With
Call UpdateToolbar
End Sub
Sub UpdateToolbar()
On Error Resume Next
CommandBars("Custom Format").Controls(1).Caption
ActiveCell.CustomFormat
End Sub
Sub FormatChanger()
Dim r As Range

For Each r In Selection

If IsNumeric(r.Value) Then
Select Case r.Value
Case 1
r.Value = "Read Only"
Case 2
r.Value = "Assessor"
Case 3
r.Value = "Reviewer"

End Select
End If
Next

Call UpdateToolbar
End Sub



Thanks
 
V

Vasant Nanavati

Haven't looked at the code in detail , but within a With ... End With block,
you need to preface properties and methods with a period to relate them to
the With statement. For example:

With NewBtn
..Caption = " "
..OnAction = "FormatChanger"
..TooltipText = "Click to change the Custom format"

etc.
 
E

excel_naive

Hi Vasant,
Thanks for your reply...I am kinda confused with u
ans I am not really sure what did u intend to tell me.....Again, I a
not even sure if this code will work to give me the result
want..Infact this code is adding another menu item in th
View-Toolbar-Custom ....but I dont want that I want to add
button/menu item in the format menu not the view menu...
Can you plzz help me modify this code to do that??:confused
 

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

Similar Threads


Top