Command Bar Menu - Management

  • Thread starter Thread starter kraljb
  • Start date Start date
K

kraljb

I am not a programmer, but somehow I got assigned this task for knowin
enough about excel functions.


I am having an issue, where I have a general custom menu called Report
where I have a few macros running reports for a few people. However
different people within that group have individual reports, as well a
individuals that do not have the general reports may have an individua
one.

The problem I am running into, while trying to be consistent across th
board, is that all the reports (individual or general) are trying to us
the same menu name: "Reports" so if an individual has multiple report
from seperate macros they end up with 2-3 different menu choices whe
all three macros are opened. I need a way to say I
reportmenudoesnotexist Then create reportmenu End If
 
This will insert the Reports Menu just in front of Help, if it doesn't
already exist:

Dim ctlReports As CommandBarControl
With CommandBars(1)
On Error Resume Next
Set ctlReports = .Controls("Reports")
On Error GoTo 0
If ctlReports Is Nothing Then
Set ctlReports = .Controls.Add( _
Type:=msoControlPopup, _
Before:=.FindControl(Id:=30010).Index, _
Temporary:=True)
ctlReports.Caption = "Reports"
End If
End With
 
Generally, it would be something like

On Error Resume Next
Set oCB = Application.CommandBars("myReports")
On Error GoTo 0

If oCB Is Nothing Then
'CreateIt
End If

but show us the code if this doesn't solve it
 

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

Back
Top