Consulting

Results 1 to 13 of 13

Thread: What is your answer about this Question!

  1. #1
    VBAX Regular
    Joined
    Dec 2012
    Location
    Kabul - Afghanistan
    Posts
    40
    Location

    Exclamation What is your answer about this Question!

    Hi Dear Friends!
    I need a Macro do disable All Ribbons and menu. but we can edit the excel file like writing or other except using Ribbons and menu. thanks.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    ...disregard.

  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Quote Originally Posted by Esmatullah
    Hi Dear Friends!
    I need a Macro do disable All Ribbons and menu. but we can edit the excel file like writing or other except using Ribbons and menu. thanks.
    You cannot disable everything!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    You can't do in in VBA (probably -- I can't anyway), but in the CustomUI it's easy


    [vba]
    <!-- This is example : Excel 2007 Dictator(1).xlsm -->
    <
    customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
     
    <!--
    **************************************************************************-->
    <!--
    ****Disable 'Exit Excel' and 'Excel Options' on the Office Button menu****-->
    <!--
    **************************************************************************-->
    <
    commands>
    <
    command idMso="ApplicationOptionsDialog"enabled="false"/>
    <
    command idMso="FileExit"enabled="false"/>
    </
    commands>
     
     
    <!--
    *******************************************************************-->
    <!--
    *****Set startFromScratch to true to hide the Ribbon and QAT*******-->
    <!--
    ********Hide New, Open and Save on the Office Button menu**********-->
    <!--
    **************Hide Contextual tabs on the Ribbon*******************-->
    <!--
    *******************************************************************-->
     
    <!--
    Set startFromScratch to true to hide the Ribbon and QAT-->
    <
    ribbon startFromScratch="true">
    <!--
    startFromScratch="true" hides all of the Ribbon tabs and it hide the QAT. -->
    <!--
    It also hides most of the commands on the Office Button menu, but for -->
    <!--
    some reason, it does not hide the 'New', 'Open' and 'Save' commands. -->
    <!--
    Also it not hides the Contextual tabs on the ribbon, for example the -->
    <!--
    Format tab that you see when you select a picture on your worksheet. -->
    <!--
    So if you want to hide them you must use the RibbonX below: -->
    <
    contextualTabs>
    <
    tabSet idMso="TabSetSmartArtTools"visible="false" />
    <
    tabSet idMso="TabSetChartTools"visible="false" />
    <
    tabSet idMso="TabSetDrawingTools"visible="false" />
    <
    tabSet idMso="TabSetPictureTools"visible="false" />
    <
    tabSet idMso="TabSetPivotTableTools"visible="false" />
    <
    tabSet idMso="TabSetHeaderAndFooterTools"visible="false" />
    <
    tabSet idMso="TabSetTableToolsExcel"visible="false" />
    <
    tabSet idMso="TabSetPivotChartTools"visible="false" />
    <
    tabSet idMso="TabSetInkTools"visible="false" />
    </
    contextualTabs>
     
    <!--
    You can add xml here to create your own custom tab on the ribbon-->
     
    </
    ribbon>
    </
    customUI>
    [/vba]

    The XML is from one of the Samples
    Attached Files Attached Files

  5. #5
    VBAX Regular
    Joined
    Dec 2012
    Location
    Kabul - Afghanistan
    Posts
    40
    Location
    But this is not valid VBA. When i type this Vba it Goes All red

  6. #6
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    The above is an xml that you can import in to excel, as Paul said you can't do it in VBA.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  7. #7
    You may not be able to disable the menu and ribbon. But you can hide them.

    [vba]
    Sub HideRibbon()
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
    End Sub
    [/vba]

  8. #8
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    For future posts, please make your subject line more meaningful.

    See if this helps using the CustomUI. http://www.rondebruin.nl/ribbonx20072010.htm

  9. #9
    VBAX Regular
    Joined
    Dec 2012
    Location
    Kabul - Afghanistan
    Posts
    40
    Location
    But where i Can the XML code and how to Import it to Excel.

  10. #10
    VBAX Regular
    Joined
    Dec 2012
    Location
    Kabul - Afghanistan
    Posts
    40
    Location
    Dear Friend!
    your XML Code is not Working. It says Invalid xml Code

  11. #11
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    I gather by "it" you mean the Validate button from the Custom UI Editor.

    Posting code here is not always perfect. XML code is NOT VBA code so let's see if Code tags work better. What the editor's Validate button is telling you is that you need a space character between options. That is how it delimits the command options.

    I tested Paul's code in my x:\xml\CustomUI.xlsm file. I also changed the schema line for Excel 2010.

    <!-- This Is example : CustomUI.xlsm --> 
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> 
      
    <!-- **************************************************************************--> 
    <!-- ****Disable 'Exit Excel' and 'Excel Options' on the Office Button menu****-->
    <!-- **************************************************************************--> 
    <commands> 
    <command idMso="ApplicationOptionsDialog" enabled="false"/> 
    <command idMso="FileExit" enabled="false"/> 
    </commands> 
      
      
    <!-- *******************************************************************--> 
    <!-- *****Set startFromScratch To True To hide the Ribbon And QAT*******--> 
    <!-- ********Hide New, Open And Save on the Office Button menu**********--> 
    <!-- **************Hide Contextual tabs on the Ribbon*******************--> 
    <!-- *******************************************************************--> 
      
    <!-- Set startFromScratch To True To hide the Ribbon And QAT--> 
    <ribbon startFromScratch="true"> 
    <!-- startFromScratch="true" hides all of the Ribbon tabs And it hide the QAT. --> 
    <!-- It also hides most of the commands on the Office Button menu, but For --> 
    <!-- some reason, it does Not hide the 'New', 'Open' and 'Save' commands. -->
    <!-- Also it Not hides the Contextual tabs on the ribbon, For example the --> 
    <!-- Format tab that you see when you select a picture on your worksheet. --> 
    <!-- So If you want To hide them you must use the RibbonX below: --> 
    <contextualTabs> 
    <tabSet idMso="TabSetSmartArtTools" visible="false" /> 
    <tabSet idMso="TabSetChartTools" visible="false" /> 
    <tabSet idMso="TabSetDrawingTools" visible="false" /> 
    <tabSet idMso="TabSetPictureTools" visible="false" /> 
    <tabSet idMso="TabSetPivotTableTools" visible="false" /> 
    <tabSet idMso="TabSetHeaderAndFooterTools" visible="false" /> 
    <tabSet idMso="TabSetTableToolsExcel" visible="false" /> 
    <tabSet idMso="TabSetPivotChartTools" visible="false" /> 
    <tabSet idMso="TabSetInkTools" visible="false" /> 
    </contextualTabs> 
      
    <!-- You can add xml here To create your own custom tab on the ribbon--> 
      
    </ribbon> 
    </customUI>

  12. #12
    VBAX Regular
    Joined
    Dec 2012
    Location
    Kabul - Afghanistan
    Posts
    40
    Location
    Thanks. I have Got it.
    I like to be help full to my dear friends and I like Help full friends. Because ( A Friend in need is A Friend in dead)

  13. #13
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Another thing to do would be to use the CustomUI editor on the attachment to my Post#4 and pull the XML out

    You can copy/paste it into your own workbook's CustomUI section

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •