How To Create MenuCommand Bar by VBA

K

kapusta117

Hello

I m working in ACCESS 2000 ...i m trying for the first time creating
Commanbar Menu..
WHEN i'm executing tHE vba code below (from a Macro) :

Public Function CreerMenu()
'
======================================================================================
' Auteur : Starec - Philippe JOCHMANS -
http://starec.developpez.com
' Description : Création d'une barre de menu

'=======================================================================================

' ==== déclaration =====
'Dim cmb As Office.CommandBars


' ===== affectation =====
' Set cmb = Application.CommandBars.Add("MaBarre", msoBarTop, True, True)

' ===== rendre la barre visible =====
'cmb.Application.Visible = True


' MsgBox "test"

End Function




I HAVE A MESSAGE ERROR Telling me that the expression has undefined function;
Although this function exist ( i tested

Public Function CreerMenu()
msgbox "TEST"
end function


launch this code by MACRO worked properly.


I HAVE TO MENTION that i 'm using Microsoft office 9.0 OBJECT that normaly
suit with ACCESS 2000

Thank you for you help
 
K

kapusta117

Hello

I have resolved ..this probleme It was a probleme linked with micrsoft object
librairies...

I have succeed creating my MenuBarr BUT i dont know How to put mu MenuBarr
Inside MY FORM and not showing it inside STANDAR ACCESS Menus

Could you help me?

Thank you
 
R

Rick Brandt

Hello

I have resolved ..this probleme It was a probleme linked with micrsoft
object librairies...

I have succeed creating my MenuBarr BUT i dont know How to put mu
MenuBarr Inside MY FORM and not showing it inside STANDAR ACCESS Menus

Could you help me?

Access forms do not support embedded menus or tool-bars. These always
live in the main Access window.

You can fake it by using labels that display shortcut menus or perform
actions when clicked.
 
K

kapusta117 via AccessMonster.com

Helllo

THANK YOU
I have juste Realized this ...AS YOU SEE i could USE LABELS....i realized
that MY WAS at INDEPANDANT WINDOW...that s normal that The created VBA
COMMANDBAR is hideen...

SO i just now change the format of my form SO the Menubar is shown just at
the top ( at same time i hide the others standard Access MenuBar) ....Rother
THAN using Lable AS you said....


NOW ALLTHING ARE OKEY ...I HAVE changed the height and the width OF my
toolbar (commanbar)
like THAT :
Set cmb = Application.CommandBars.Add("MaBarre", msoBarTop, True, True)



' ===== ajout de boutons =====
Set btn = cmb.Controls.Add(msoControlButton)
With btn
.Caption = "&Bouton 1"
.Style = msoButtonCaption
.Height = 60
.Width = 200
End With
Set btn = cmb.Controls.Add(msoControlButton)
With btn
.Caption = "B&outon 2"
.Style = msoButtonCaption
.Height = 60
.Width = 200

End With


BUT i dont find the PROPERTY that allow me change the size OF the texte
caption of the button

something like .SIZE=15 SO the width and height of my commandBar COULD
FIT with the texte inside


THank youu veryy Much
 

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