What would be the alternative for 'Office.CommandBar' in Office 365 for MS Access


Board Regular

I have below lines in my code.

Dim MyOrig As Office.CommandBar
Set MyOrig = CommandBars("Menu Bar")

Dim MyMAIN As CommandBar
Set MyMAIN = CommandBars.ActiveMenuBar

What would be the alternative for 'Office.CommandBar' in Office 365 for MS Access.
This code is written in older version of Access and I need to make it work in Office 365.

I am pretty blank in this scenario, kindly pardon my ignorance.
Can anyone please help me in this.
Last edited:


Well-known Member
according to this


it seems like it should still work

[h=2]Existing solutions[/h][FONT=&quot]In versions of Office previous to Office 2007, developers used the CommandBars object model to create the Visual Basic code that modified the UI. In Office, this legacy code continues to work in most cases without modification. However, changes made to toolbars in Office 2003 now appear on an Add-Ins tab in Office.[/FONT]
here's more examples of the CommandBar code



and at the bottom of that very first link is a link to the new way of doing it, but I haven't tried it



Board Regular
I tried below code in both Office 365 and Access 2010.
I was not able to see any difference or bug in any of the environment for this code.

Kindly pardon my ignorance, am new to Access and from Excel background.

If this code is working fine in both versions, what can go wrong here.
I am told that these kind of code lines will not work in Office365 environment.

I tried doing running this code by doing F8. And it ran without any bug.

Hence I assumed code is running without any issues in both the versions.
Am I correct. Can anyone please help me in this.

[FONT=Calibri][COLOR=#000000]Option Compare Database[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Sub Test()[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Dim MyOrig As Object[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Set MyOrig = CommandBars("Menu Bar")[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Dim MyMAIN As Object[/COLOR][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]    [FONT=Calibri]Set MyMAIN = Application.CommandBars("MenuBar")[/FONT]
[FONT=Calibri]Dim MyObj As Object[/FONT]
[/COLOR][/SIZE][SIZE=3][COLOR=#000000]Set MyObj =Application.CommandBars("Menu Bar")[/COLOR][/SIZE][/FONT]

[FONT=Calibri][COLOR=#000000]End Sub[/COLOR][/FONT]
Last edited:


Well-known Member
Did you look for this old toolbar or menu in the Quick Access area of the ribbon? If I recall, that's where it will show up but it's not obvious.
Can't recall what happens if you hide the main ribbon; i.e. does it hide the QA menu as well, thus your old tb is not available? Or does it make your tb appear like it did in older versions?

You might want to explore the idea of converting your old tb to the updated ribbon.
Last edited:

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...