+ Reply to Thread
Results 1 to 6 of 6

Disabling save as option to protect macro code

  1. #1
    Registered User
    Join Date
    06-09-2011
    Location
    Leeds, UK
    MS-Off Ver
    MS Office 2016
    Posts
    77

    Question Disabling save as option to protect macro code

    I have a macro file which as has a button which, when clicked, fetch data from Master data tab based on the user's access level. Access is defined under Access tab. Both Access tab and Master Data tab are "VeryHidden" in VBA editor and protected by password so that user can't access it.

    Now the issue is, if i save the file as xlsx or other format macro code including password is getting removed. Then i can make Master data tab visible without entering any password. That means anyone can view VeryHidden data.

    Is there any solution to this? Is it possible disable Save as (other format) option while normal save option remains active.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Disabling save as option to protect macro code

    Hi there,

    See if the following code does what you need - it should be inserted in the "ThisWorkbook" VBA CodeModule:

    Please Login or Register  to view this content.
    Note that this code should be inserted into a workbook which has already been saved at least once, otherwise the warning message will be displayed.


    Hope this helps.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    06-09-2011
    Location
    Leeds, UK
    MS-Off Ver
    MS Office 2016
    Posts
    77

    Re: Disabling save as option to protect macro code

    Thanks. Its working but when I open the file I'm getting Compatibility error (attached).
    Attached Images Attached Images

  4. #4
    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,466

    Re: Disabling save as option to protect macro code

    Maybe put the Master data worksheet in a separate workbook and protect that. In the separate workbook, have Sheet1 visible.

    Lock and hide content on Master sheet. Protect Master sheet with password . . . no selection of locked/unlocked cells. Set Master sheet to xlVeryHidden. Protect VBA Project with a password.

    This is a theoretical and untested approach but I think you need to try and separate the Master sheet.

    Excel is not a secure environment so anything in the original workbook is fair game to a determined hacker, amateur or otherwise.
    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


  5. #5
    Registered User
    Join Date
    06-09-2011
    Location
    Leeds, UK
    MS-Off Ver
    MS Office 2016
    Posts
    77

    Re: Disabling save as option to protect macro code

    I think i figured out what is causing compatibility issue - The "Option Explicit" command. I've removed it and error is gone. This code is now working fine. Save As option is disabled.
    BTW this code was working before as well, only that annoying compatibility msg was appearing every time i open the file.
    Thanks all for your help.

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Disabling save as option to protect macro code

    Hi again,

    Many thanks for your feedback - much appreciated!

    You're welcome - glad I was able to help.

    Regards,

    Greg M

+ 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. How to Protect worksheet-deactivate 'save as, cut/copy/paste option
    By azmir in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 10-07-2017, 10:15 PM
  2. Problem in Enabling/Disabling insert Option Using Macro
    By mangaldeep in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-02-2013, 06:47 AM
  3. [SOLVED] Disabling an Entire Frame with Option Buttons if other Option Buttons are not clicked.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-20-2012, 04:07 AM
  4. Disabling SAVE option in a worknook
    By mkssaravanan in forum Excel General
    Replies: 6
    Last Post: 12-10-2011, 11:05 AM
  5. Disabling Option to Delete using VB Code
    By ltmaiyk in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2010, 06:21 PM
  6. [SOLVED] Disabling "SAVE AS" option under "File"
    By Bidyut Bhattacharjee in forum Excel General
    Replies: 3
    Last Post: 03-22-2006, 02:40 PM

Tags for this Thread

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