' customize classic UI in access
' taken from Example05.vb

Private Sub Example05Main()

   Dim commandBar As Office.CommandBar = Nothing
   Dim commandBarBtn As Office.CommandBarButton = Nothing

   ' start access 
   _accessApplication = New Access.Application()

   ' add a commandbar popup
   Dim commandBarPopup As Office.CommandBarPopup = _
_accessApplication.CommandBars("Menu Bar").Controls.Add(MsoControlType.msoControlPopup) commandBarPopup.Caption = "commandBarPopup" ' you can see we use an own icon via .PasteFace() ' is not possible from outside process boundaries to use the PictureProperty ' directly the reason for is IPictureDisp:
' http://support.microsoft.com/kb/286460/de
' its not important is early or late binding or managed or unmanaged,
‘ the behaviour is always the same
' For example, a COMAddin running as InProcServer and can access the Picture Property ' add a button to the popup commandBarBtn = commandBarPopup.Controls.Add(MsoControlType.msoControlButton) commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption commandBarBtn.Caption = "commandBarButton" Clipboard.SetDataObject(Me.Icon.ToBitmap()) commandBarBtn.PasteFace() Dim clickHandler As Office.CommandBarButton_ClickEventHandler = _
AddressOf Me.commandBarBtn_Click AddHandler commandBarBtn.ClickEvent, clickHandler ' make visible & set buttons _accessApplication.Visible = MsoTriState.msoTrue button1.Enabled = False button2.Enabled = True End Sub Private Sub commandBarBtn_Click(ByVal Ctrl As Office.CommandBarButton, ByRef CancelDefault As Boolean) textBoxEvents.BeginInvoke(_updateDelegate, New Object() {"Click called."}) Ctrl.Dispose() End Sub Private Sub UpdateTextbox(ByVal message As String) textBoxEvents.AppendText(message & vbNewLine) End Sub

Last edited Jun 13, 2012 at 1:59 PM by SebastianDotNet, version 6