Cicle through CommandBars

  • Thread starter Thread starter ALESSANDRO Baraldi
  • Start date Start date
A

ALESSANDRO Baraldi

I need to cicle throught CommandBarPupup because
i need to Change Icon, Descriprion and Function Colled
by code......!

I try with this:

cboMnu=ComboBox containing my PopUp List Menù
i fill this Comboo on Form Load Event all OK right now

Private Sub Form_Load()
Dim cbr As CommandBar
Dim strMnu As String
For Each cbr In Application.CommandBars
If InStr(cbr.name, "mnu_Popup") Then
strMnu = strMnu & cbr.name & ";"
End If
Next
Me.cboMnu.RowSource = strMnu
End Sub

after to have chosen my PopupMenù i Need to
chose a single Control, so i need to Fill my ListBox
with all Controls collection on After_Update Combo
Event:


Private Sub cboMnu_AfterUpdate()
Dim cb As CommandBar, cbpTools As CommandBarPopup
Dim cbTool As CommandBar
Dim intTotalCurrent As Integer, intCurrControl As Integer
Dim strMnu As String
'***************** In the Next Row i Receive Error **************
'***************** Type no corresponding (sorry for English) ******

Set cb = CommandBars(Me.cboMnu)
Set cbpTools = cb.FindControl(Type:=msoControlPopup)
Set cbTool = cbpTools.CommandBar
intTotalCurrent = cbTool.Controls.count
For intCurrControl = 1 To intTotalCurrent
strMnu = strMnu & cbTool.Controls(intCurrControl ).DescriptionText
Next
End Sub


I don't know why and where i make mistake....!
I use A2002, Referenced by Microsoft Office 10.0, DAO 3.6

Someone can Help me....?
Thank you very much.
 
Set cb = CommandBars(Me.cboMnu)

Set cb = Application.CommandBars(Me.cboMnu)

(david)
 
david epsom dot com dot au said:
Set cb = Application.CommandBars(Me.cboMnu)

(david)

[CUT]

Thank, but is not the solution to my mistake....!
Don't work.

I really don't know where is the problem....!

@Alex.
 
ALESSANDRO Baraldi said:
david epsom dot com dot au said:
Set cb = Application.CommandBars(Me.cboMnu)

(david)

[CUT]

Thank, but is not the solution to my mistake....!
Don't work.

I really don't know where is the problem....!

@Alex.


I find the problem.... but i don't know why....!
If i use Object Type variable declaretion all work good
instead of CommandBar it's OK....!

Anyone know this problem.....?

@Alex.
 
ALESSANDRO Baraldi said:
ALESSANDRO Baraldi said:
david epsom dot com dot au said:
Set cb = CommandBars(Me.cboMnu)

Set cb = Application.CommandBars(Me.cboMnu)

(david)

[CUT]

Thank, but is not the solution to my mistake....!
Don't work.

I really don't know where is the problem....!

@Alex.


I find the problem.... but i don't know why....!
If i use Object Type variable declaretion all work good
instead of CommandBar it's OK....!

Anyone know this problem.....?

@Alex.


To dim As Commandbar, you need a reference to the Office library. To dim As
Object, you do not need that reference.

Is that it?

HTH,
TC
 
"TC" <[email protected]> ha scritto nel messaggio
[CUT]
To dim As Commandbar, you need a reference to the Office library. To dim As
Object, you do not need that reference.

Is that it?

HTH,
TC


;-)

If you have read the first message to the end
i have said about my Microsoft Office 10.0 Reference, all OK.

I know this, but the strange things is that using the proper
VarType don't work.
Now it work good, but not as I want...........!!!

I want to understand where mistake and why does not work

I'm sure that the mistake is in the second Sub:

Private Sub cboMnu_AfterUpdate()
Dim cb As CommandBar, cbpTools As CommandBarPopup
Dim cbTool As CommandBar
Dim intTotalCurrent As Integer, intCurrControl As Integer
Dim strMnu As String
'***************** In the Next Row i Receive Error **************
'***************** Type no corresponding (sorry for English) ******
'Microsoft Office 10.0 Libray Checked

Set cb = CommandBars(Me.cboMnu)
Set cbpTools = cb.FindControl(Type:=msoControlPopup)
Set cbTool = cbpTools.CommandBar
intTotalCurrent = cbTool.Controls.count
For intCurrControl = 1 To intTotalCurrent
strMnu = strMnu & cbTool.Controls(intCurrControl ).DescriptionText
Next
End Sub


I need Help about this....!

Goog evening....!
@Alex.
 
This is the Solution:

Private Sub Form_Load()
Dim cbr As CommandBar
Dim strMnu As String
For Each cbr In Application.CommandBars
If InStr(cbr.name, "mnu_Popup") Then
strMnu = strMnu & cbr.name & ";"
End If
Next
Me.cboMnu.RowSource = strMnu
End Sub


Private Sub cboMnu_AfterUpdate()
Dim cbCBars As CommandBar
Dim cbc As CommandBarControl ' Object
Dim x As Integer
Dim strMnu As String
For Each cbc In CommandBars(Me.cboMnu.value).Controls
strMnu = strMnu & cbc.Caption & " - " & cbc.OnAction & " - " &
cbc.FaceId & ";"
Next
Me.lstCbr_mnu.RowSource = strMnu
End Sub
 
:~) I see :~)

Works:

set cb = CommandBars(Me.cboMnu.value)

Doesn't work:

set cb = CommandBars(Me.cboMnu)


(david)
 
david epsom dot com dot au said:
:~) I see :~)

Works:

set cb = CommandBars(Me.cboMnu.value)

Doesn't work:

set cb = CommandBars(Me.cboMnu)


(david)


Yess.... the must important Error is really this difference....!
Thank's.

@Alex.
 
Back
Top