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

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,742
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.
 

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
Hi Micron sir, thanks a lot for the help.
Yes, I have back-up with me.

Have a nice day ahead. :)
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,526
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.
 

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
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.
 

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
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.
 

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
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
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,526
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.
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,742
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.
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,526
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:
 

Forum statistics

Threads
1,078,286
Messages
5,339,303
Members
399,292
Latest member
Bdbd55

Some videos you may like

This Week's Hot Topics

Top