+ Reply to Thread
Results 1 to 11 of 11

Hide ribbons when Macros are disabled

  1. #1
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28

    Hide ribbons when Macros are disabled

    Hello,

    I have developed some excel programms using VBA. However, I have noticed that there are some programs available on Internet which breaks the workbook / worksheet passwords. Hence, I have added a code (Macro) to hide ribbons. But, it works when Macros are enabled.

    Hnece, want to know how to hide ribbons when marcos are disabled.

    Thank you,

    xlman

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Hide ribbons when Macros are disabled

    I dont think you can as the macro will need to be triggered, can you hide them before save, and then show on a macro?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Hide ribbons when Macros are disabled

    You can use the getVisible callback to make tabs visible. Of course if macros are not enabled they will not be shown.

    Not sure how hiding the ribbon protects your code though
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Hide ribbons when Macros are disabled


  5. #5
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Hide ribbons when Macros are disabled

    Hide ribbons on Workbook_BeforeClose sub. On Workbook_open enable ribbons/
    If macros will be disabled then the ribbons will not be shown.
    It is the simpliest and weakest way to protect your file.

    may be this will help: http://www.ozgrid.com/VBA/excel-add-in-create.htm
    Last edited by lancer102rus; 08-15-2014 at 06:34 AM.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Hide ribbons when Macros are disabled

    Thinking about this if your are worried about users using another workbook to break yours doing stuff to the ribbon will have no affect.
    When they open the other workbook it will display it's own ribbons.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,491

    Re: Hide ribbons when Macros are disabled

    @Andy: I'm having a blonde moment or, more accurately, a grey moment. Can you explain the process here, please. Do you have to do something to the workbook before you save and close it? Or can you just insert that code into any macro enabled workbook? Clearly, it's not as simple as that ... I just tried. So how do you prepare the workbook so that this works?

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Hide ribbons when Macros are disabled

    I did forget to mention you need to add ribbon xml to the file.

    <customUI
    xmlns="http://schemas.microsoft.com/office/2006/01/customui"
    onLoad="rbxUI_onLoad">
    <ribbon >
    <tabs >
    <tab
    idMso="TabHome"
    getVisible="HasMacros"/>
    <tab
    idMso="TabInsert"
    getVisible="HasMacros"/>
    <tab
    idMso="TabPageLayoutExcel"
    getVisible="HasMacros"/>
    <tab
    idMso="TabFormulas"
    getVisible="HasMacros"/>
    <tab
    idMso="TabData"
    getVisible="HasMacros"/>
    <tab
    idMso="TabReview"
    getVisible="HasMacros"/>
    <tab
    idMso="TabView"
    getVisible="HasMacros"/>
    <tab
    idMso="TabDeveloper"
    getVisible="HasMacros"/>
    <tab
    idMso="TabAddIns"
    getVisible="HasMacros"/>
    <tab
    idMso="TabPrintPreview"
    getVisible="HasMacros"/>
    </tabs >
    </ribbon >
    </customUI >

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,491

    Re: Hide ribbons when Macros are disabled

    Okay ... I'm beginning to feel like a 5 year old now

    ... you need to add ribbon xml to the file.
    How do you do that then?

    Regards, TMS

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Hide ribbons when Macros are disabled

    You can either do it manually by changing to zip file and editing files within the zip folder.
    Or use some tool created to do it.

    They is lots of information here
    http://www.rondebruin.nl//win/section2.htm

    and I have a tool and some information here
    http://www.andypope.info/vba/ribboneditor.htm
    http://www.andypope.info/vba/ribboneditor_2010.htm

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,491

    Re: Hide ribbons when Macros are disabled

    @Andy: Thank you. Looks interesting (and very useful). Cheers

  12. #12
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28

    Re: Hide ribbons when Macros are disabled

    Hey Andy,

    Awsome... You have done it. It works like a charm.
    I can see only 1 tab "PDF", when macros are disabled... rest are gone...

    @TMS, you spelled my queris, that made it simple for me.

    Thanks both & Regards,

    xlman

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,491

    Re: Hide ribbons when Macros are disabled

    @xlman: you're welcome, glad to have been of help. I had to ask, it's not something I've done either.

    Regards, TMS



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macros enabled workbook keeps saying macros are disabled
    By joker3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-15-2013, 11:28 PM
  2. Replies: 5
    Last Post: 07-26-2012, 09:38 PM
  3. Macros are disabled
    By mkingsley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2005, 02:05 PM
  4. Macros disabled
    By FJB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-12-2005, 09:05 PM
  5. Disabled Macros
    By MBlake in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2005, 11:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1