none
Macro for manipulating menus (not button) RRS feed

  • Question

  • Hi,

    I'm dealing with menus of Traditional Chinese MS Word / Excel to do the following things:

    con_FILE = "File"

    If IsMenuItemExist(CommandBars("Menu Bar").Controls(con_FILE).Controls, "Upda&te") = True Then
        CommandBars("Menu Bar").Controls(con_FILE).Controls("Upda&te").OnAction = ""
    End If

    What it makes is to make check and unset the OnAction of the "Update" control of "File" Menu Bar.

    However, when I put these codes into Chinese MS Word / Excel, it screws up because -- CommandBars("Menu Bar").Controls(con_FILE).Controls -- does not exist, but if con_FILE = "檔案", which is the Chinese translation of File, then it works. And for MS Word / Excel 2010, it makes more complicated to concatenate more strange characters at the end...

    I want to implement a permanent solution, such that for whatever language of MS Office in whatever version (2003, 2007, 2010), when I point the Controls of that unique identifier, then I point to the currect control of controls / command bar. I'm sure another attribute, Index, is not a unique identifier. Also, this identifier needs to be the same for all languages of MS Word / Excel, and the menu item can be called easily or at most iterating the command bar / control objects. Do you have any suggestions?

    I read thru online and found that there is something called FaceId. I'd like to ask if FaceId is a valid identifier or I need to use others? Also, is this the same for all languages of MS Word / Excel? Also, how to call the control by the FaceId, or need to do it by iterating the command bar / control objects?

    Thanks!

    Wednesday, January 18, 2012 3:20 AM

Answers

  • Hi,

    I'm dealing with menus of Traditional Chinese MS Word / Excel to do the following things:

    con_FILE = "File"

    If IsMenuItemExist(CommandBars("Menu Bar").Controls(con_FILE).Controls, "Upda&te") = True Then
        CommandBars("Menu Bar").Controls(con_FILE).Controls("Upda&te").OnAction = ""
    End If

    What it makes is to make check and unset the OnAction of the "Update" control of "File" Menu Bar.

    However, when I put these codes into Chinese MS Word / Excel, it screws up because -- CommandBars("Menu Bar").Controls(con_FILE).Controls -- does not exist, but if con_FILE = "檔案", which is the Chinese translation of File, then it works. And for MS Word / Excel 2010, it makes more complicated to concatenate more strange characters at the end...

    I want to implement a permanent solution, such that for whatever language of MS Office in whatever version (2003, 2007, 2010), when I point the Controls of that unique identifier, then I point to the currect control of controls / command bar. I'm sure another attribute, Index, is not a unique identifier. Also, this identifier needs to be the same for all languages of MS Word / Excel, and the menu item can be called easily or at most iterating the command bar / control objects. Do you have any suggestions?

    I read thru online and found that there is something called FaceId. I'd like to ask if FaceId is a valid identifier or I need to use others? Also, is this the same for all languages of MS Word / Excel? Also, how to call the control by the FaceId, or need to do it by iterating the command bar / control objects?

    Thanks!

    Hi,

    You should be aware of that CommandBars is superseded by Ribbon component from Office 2007. If you want to change Office UI within one add-in, you would have to give up VBA procedures, using some technology like Shim add-in instead.

    I hope this helps.


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us
    Friday, February 3, 2012 8:59 AM
    Moderator