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:
It removes a menu option that has a name or caption like "Help for MyProject"
I hope you are keeping backup files as you go because it seems like you're modifying command bars without understanding what you're doing.
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi Micron sir, thanks a lot for the help.
Yes, I have back-up with me.

Have a nice day ahead. :)
 
Upvote 0
This is deleting an item on the command bar but since you don't have the command bar I think it's probably not needed anymore and the code can be removed.

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

This code cannot affect output. It can only affect a UI control.
 
Upvote 0
Hi @xenou sir thanks a lot for the help.

Please pardon my ignorance. Could you please help if you get time.
I have FORMS in my macro and there is RIBBON of Access.
When we say, this will affect UI control, does it mean that it will also affect FORM options.

For example, I have button on my Form, is there a possibility of this code affecting buttons on Form too.
The reason am asking is, then I need to think and work on those issues as well.
 
Upvote 0
Apologies, my time limit expired to edit the post.
Some of these code lines are written in 'Form' module and some of the lines are written in normal module.
That is why am not sure about UI impact.
 
Upvote 0
Hi,

This is the Function that is supposed to run in Office 365 version of MS access.
This Function is in 'Form' module of my macro and called from the same module of Form.

My initial doubt was if 'Set MyMenuBar = Application.CommandBars("Menu Bar")' this line will work in both the versions.
Please pardon me for not providing the entire code earlier.

My understanding of the code is, 'MyNew' is dependent of 'MyMenuBar'.
And 'MyObject_1' depends on 'MyNew'.

If 'MyMenuBar' does not work then this function will not work.
I tried running this code in Office365 but did not face any issue.
Trying again to check the issues.

Can you please help me understand does running this code in Office 365 will have any issue.

VBA Code:
Option Compare Database
Private Function MyFunction() As Object
    Dim MyObject_1 As Object
    Dim MyMenuBar As Object
    Dim MyNew As Object
    
    On Error GoTo Err_Add_About_CommandBar_Item
    
    Set MyMenuBar = Application.CommandBars("Menu Bar")
    Set MyNew = MyMenuBar.Controls.ADD(Type:=ddCommandBars.ControlPopup, Temporary:=True)
    MyNew.Caption = "Hel&p for " & TempVars!MyProject
    
    Set MyObject_1 = MyNew.Controls.ADD(Type:=ddCommandBars.ControlButton, ID:=1)
    
    With MyObject_1
        .Caption = "&About " & TempVars!MyProject
        .TooltipText = "About This Database"
        .Style = ddCommandBars.ButtonIconeAndCaption
        .OnAction = "ShowVCForm"
        .FaceId = 487
    End With
    
    Set MyObject_1 = MyNew.Controls.ADD(Type:=ddCommandBars.ControlButton, ID:=1)
    
    With MyObject_1
        .Caption = "&Instruction here"
        .TooltipText = "same Instruction here"
        .Style = ddCommandBars.ButtonIconeAndCaption
        .OnAction = "MyModuleName"
        .FaceId = 1753
    End With
    
Exit_Add_About_CommandBar_Item:
    Set MyNew = Nothing
    Set MyObject_1 = Nothing
    Set MyMenuBar = Nothing
    Exit Function
    
Err_Add_About_CommandBar_Item:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Add_About_CommandBar_Item of Module basFormsReports"
    Resume Exit_Add_About_CommandBar_Item
End Function
 
Upvote 0
I don't believe office 365 has command bars anymore. It uses ribbon controls. On the other hand this code shouldn't do any harm either. At worst it will do nothing.
 
Upvote 0
I don't believe office 365 has command bars anymore. It uses ribbon controls. On the other hand this code shouldn't do any harm either. At worst it will do nothing.
As I may or may not have already mentioned here, they should appear in the Add Ins menu if the code works.
 
Upvote 0
Thank you - yes I couldn't remember what tab that was but pre-ribbon command bar customizations can show up on the ribbon on the addins tab.

For rewriting the code you really have to remove it and implement ribbon controls instead (not quite as easy as it used to be but I guess not hard once you work through the process a few times and understand how it works).

Just posted some links on this in this thread yesterday:
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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