+ Reply to Thread
Results 1 to 9 of 9

Would like to hide specific text inside macro vba code

  1. #1
    Registered User
    Join Date
    10-16-2012
    Location
    ma
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question Would like to hide specific text inside macro vba code

    Working on an Excel document that has several password-protected tabs (i.e. worksheets). These "protected" tabs include working macros with code that effectively unprotects the tab, runs the macro, and then re-protects the tab before exiting.

    Here's a sample:
    _________________

    Please Login or Register  to view this content.
    _________________


    If possible, I'd like to HIDE the 2 lines of code above that make reference to the password. Is there any way to change a line of code's text color to match the background color, thereby making the line invisible to the reader?

    Appreciate any suggestions here.

    Thank you.

    - Kevon
    Last edited by Cutter; 10-17-2012 at 09:00 AM. Reason: Added code tags

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Would like to hide specific text inside macro vba code

    No, but you could lock the project from viewing so to view the code, the user would need to know the password

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Would like to hide specific text inside macro vba code

    Hi,

    As far as I'm aware the VB editor does not give this flexibility. Seems to me that you have two options.

    1. Password protect the VB environment so that the macros can't be seen until a password opens them up.
    2. Put your password on a sheet which is 'xlVeryHidden', so that it can't be unhidden and made viewable from within the Excel application and pick up the cell containing the password in the macro rather than hard coding it in the script.

    However even with the latter, if someone wants to type Print Range("A1") in the Immediate window then they'll discover the password. Option 1 seems preferable.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    10-16-2012
    Location
    ma
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Would like to hide specific text inside macro vba code

    How do I go about locking the project, Kyle123?

    Thanks for the reply back.

  5. #5
    Registered User
    Join Date
    10-16-2012
    Location
    ma
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Would like to hide specific text inside macro vba code

    How do I accomplish option 1, Richard? Thank you.

    _____________________
    Last edited by Cutter; 10-17-2012 at 09:01 AM. Reason: Removed whole post quote

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Would like to hide specific text inside macro vba code

    Select a module, right click and select VBAProject properties where you can add a password on the Protection tab.

  7. #7
    Registered User
    Join Date
    10-16-2012
    Location
    ma
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Would like to hide specific text inside macro vba code

    Figured out how to lockdown the vba code inside the Excel doc. Any security is better than none when it comes to protecting intellectual property.

    Thanks again for the help, Kyle123.

    ____________________

    Quote Originally Posted by Kyle123 View Post
    No, but you could lock the project from viewing so to view the code, the user would need to know the password

  8. #8
    Registered User
    Join Date
    10-16-2012
    Location
    ma
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Would like to hide specific text inside macro vba code

    Appreciate the help, Norie. Thank you.

    _____________________

    Quote Originally Posted by Norie View Post
    Select a module, right click and select VBAProject properties where you can add a password on the Protection tab.

  9. #9
    Registered User
    Join Date
    04-03-2014
    Location
    lima, peru
    MS-Off Ver
    Excel 2010 / 2013
    Posts
    7

    Cool Re: Would like to hide specific text inside macro vba code

    Hi Kevon,

    Richard's suggestion for #1 by protecting your VBA module with a password is a good one if your users don't really have much to gain from accessing your VBA. But if the VBA is important enough then people can break into it in just a few minutes. Here is a website that shows you just how easy it is to break the VBA password:
    http://datapigtechnologies.com/blog/...-vba-projects/

    If the intellectual property is important enough, then I'd recommend one of the tools out there that aim to solve these problems, such as:
    Spreadsheet Compiler: www.doneex.com
    Spreadsheet Converter: www.spreadsheetconverter.com/
    or a product that we built, called HiveLink: https://hivelink.io

    Good luck!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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