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

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
Hi,

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:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
according to this

https://docs.microsoft.com/en-us/of...concepts/overview-of-the-office-fluent-ribbon

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

https://docs.microsoft.com/en-us/office/vba/api/office.commandbar

https://docs.microsoft.com/en-us/office/vba/api/office.commandbar.controls

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

https://docs.microsoft.com/en-us/pr...e/developer/office-2010/ff863131(v=office.14)
 
Upvote 0
Hi,
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.


Code:
Option Compare Database
Sub Test()
Dim MyOrig As Object
Set MyOrig = CommandBars("Menu Bar")
Dim MyMAIN As Object
Set MyMAIN = Application.CommandBars("MenuBar")
Dim MyObj As Object
Set MyObj =Application.CommandBars("Menu Bar")

End Sub
 
Last edited by a moderator:
Upvote 0
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:
Upvote 0
Hi,
Stuck at the above mentioned query.
I ran the code in both the Office 365 and 2010.

I did not face any bug. I was not able to see any difference in the file menu in both the versions.
If I select 'Org_1' and check in Quick Watch, I can not see any value in both the versions.

Not able to understand if this code is working in Office365.
Please pardon my ignorance, but am not sure what ideal output should be for this code.
Since I am not getting any bug while running these lines, not able to determine if there is any issue.

What should I check after running these lines in 2010 that I should reconcile in Office365.
As advised, I tried checking Quick Access Area of the ribbon, but was not able to locate this either.

Only information I have is, this code was written in earlier versions of Access and won't work in Office365.
So am required to edit this code but at present am not able understand how to proceed on this.

Can anyone please help me in this.


VBA Code:
Option Compare Database
Sub Dummy_Code()
    Dim Org_1 As Object
    Set Org_1 = CommandBars("Menu Bar")
  
    Dim MyMain As Object
    Set MyMain = Application.CommandBars("Menu Bar")
  
    Dim MyLong As Object
    Set MyLong = Application.CommandBars("Menu Bar")
  
    Dim MyShortcut As Object
    Dim MyIter As Long
    MyIter = 1
    Set MyShortcut = Application.CommandBars(MyIter)
End Sub
 
Upvote 0
This code doesn't do anything. So you shouldn't expect anything to happen even if it runs successfully (except set some variables and then not do anything with them).
 
Upvote 0
Hi,

Continuing with my original post.
I have following function in my macro.

I am not able to understand what does this function do.
I guess, this function is deleting temp variables but not sure about this.

If I skip below function from my code, will it affect my output.

Or do I need to write it in other way so running this code in Office365 won't affect this function.
Can anyone please help me in this.

Please see below code for your reference. MyProject is declared as in the main module.

VBA Code:
Option Compare Database
Private Function MyFunction()
    Dim MyObject As Object
    Set MyObject = CommandBars("Menu Bar")
    
    On Error Resume Next
    MyObject.Controls("Hel&p for " & TempVars!MyProject).Delete
    Set MyObject = Nothing
End Function
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,714
Members
448,294
Latest member
jmjmjmjmjmjm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top