+ Reply to Thread
Results 1 to 12 of 12

hiding tabs until macros are enabled

  1. #1
    Registered User
    Join Date
    07-12-2010
    Location
    MI
    MS-Off Ver
    Excel 2003
    Posts
    15

    hiding tabs until macros are enabled

    The code below (found online and then altered) has allowed me to prompt the user if any cells are left blank, and it works well. However, the user can disable the macros and get around having to complete the needed data.

    I've been trying to find a code that will work with this so I can have the workbook open to a cover page (hiding all the other tabs) asking the user to open with the macros enabled.

    Because I'm unable to freely design VB code, I've been finding volunteered codes online and trying to alter them to work. So far I haven't been able to actually hide the tabs (3 of them) if opened with macros off.

    Can someone please help me write a code or send me a sample I can play with to be able to do this? We use version 2003 currently.

    Code is in "ThisWorkbook." Option Explicit is in "General/Declarations" and the rest is in "Workbook/BeforeSave."


    Please Login or Register  to view this content.
    Thank you!

  2. #2
    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
    44,436

    Re: hiding tabs until macros are enabled

    Hide the tabs in the Workbook_Before_Close event.

    They are then already hidden when the workbook is opened ... so you have to activate macros in order to unhide them. Set them to Very Hidden rather than just hiding them and protect the VB Project with a password.

    Regards
    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


  3. #3
    Registered User
    Join Date
    07-12-2010
    Location
    MI
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: hiding tabs until macros are enabled

    Can you help me out with an example code?

    "I'm unable to freely design VB code."


    Thanks a ton!!

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: hiding tabs until macros are enabled

    Hi FaurKris,
    Find the attached with code that will hide all tabs except the first one when the workbook closes. The code looks like:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    07-12-2010
    Location
    MI
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: hiding tabs until macros are enabled

    ONLY the first tab shows up.....?

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: hiding tabs until macros are enabled

    Yep - that is because in the For Loop I started with ShtCtr = 2.

    The code uses the Tab Index numbers and hides all the Tabs except the left-most Did you want to hide ones with special names?

  7. #7
    Registered User
    Join Date
    07-12-2010
    Location
    MI
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: hiding tabs until macros are enabled

    No, I just want to hide all but the first tab, but ONLY if the user disabled macros. Otherwise, I would want all but the first tab to appear. I've made the first tab to be like a cover page telling the user to stop and enable macros.

    Oh, and I pasted your code and nothing changed on my spreadsheet. I only noticed the single tab on yours. The operation of my spreadsheet did not change.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: hiding tabs until macros are enabled

    What Marvin's code does is hide all the tabs but it does not make them "very hidden" If you want the tabs to automatically reverse on opening (if the person enabled macros), then you need more code. Try these two macros in "This Workbook"
    Please Login or Register  to view this content.
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: hiding tabs until macros are enabled

    When you pasted my code, did you put it behind the Workbook module?

  10. #10
    Registered User
    Join Date
    07-12-2010
    Location
    MI
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: hiding tabs until macros are enabled

    Here are the screen shots of what I have...

    The file is still opening with all tabs showing when I elect not to enable macros.


    I appreciate all the help. Hopefully I can get this sorted soon...
    Attached Images Attached Images

  11. #11
    Registered User
    Join Date
    07-12-2010
    Location
    MI
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: hiding tabs until macros are enabled

    Okay, so I just noticed that when macros are enabled and I am asked to save, All the tabs are closed but the first one....... But that is the only time that happens.

  12. #12
    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
    44,436

    Re: hiding tabs until macros are enabled

    Maybe try:

    Please Login or Register  to view this content.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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