How to Protect VBA Code

Method 1 of 3:

Secure VBA Code with a Password

  1. How to Protect VBA Code Picture 1
    Open the Visual Basic Editor, usually found under "Macro" in the "Tools" menu. (In Access, you may need to be in the database window to reach the editor, depending on your computer set-up.)
    1. Select "Project Properties" in the "Tool" menu within the Visual Basic Editor.
      How to Protect VBA Code Picture 2
  2. How to Protect VBA Code Picture 3
    Go to the "Protection" tab.
  3. How to Protect VBA Code Picture 4
    Select the "Lock Project for Viewing" check box. If you don't check this box, you won't hide your code.
  4. How to Protect VBA Code Picture 5
    Create and confirm your desired password in the indicated boxes.
  5. How to Protect VBA Code Picture 6
    Save, close, and reopen your workbook for the protection to take effect. (In Microsoft Excel 2007 and later, you may need to save as an XLSM file for your code to work.)
Method 2 of 3:

Hide VBA Code in a Read-Only File with Access 2007

  1. How to Protect VBA Code Picture 7
    Go to the "Database Tools" tab.
  2. How to Protect VBA Code Picture 8
    Find the "Database Tools" group.
  3. How to Protect VBA Code Picture 9
    Select "Make ACCDE."
  4. How to Protect VBA Code Picture 10
    Save the ACCDE file with a separate name from the original file. That ACCDE file is a read-only file type, so you need to keep the original file, too, to be able to make any changes.
Method 3 of 3:

Protect Your VBA Code by Making an Add-In

  1. How to Protect VBA Code Picture 11
    Create an empty Office file of the type that will use your code. (For example, if your code works with MS Excel, create an Excel file.)
  2. How to Protect VBA Code Picture 12
    Copy your VBA code into the Visual Basic Editor of that empty file.
  3. How to Protect VBA Code Picture 13
    Open the "Macros" window, usually stored under "Tools."
  4. How to Protect VBA Code Picture 14
    Test your code again, which debugs it.
  5. How to Protect VBA Code Picture 15
    Remove anything added to the empty file by your test.
  6. How to Protect VBA Code Picture 16
    Add a description to the macro that will run in your add-in. (You may need to select macro "Options" to be able to insert the description.)
  7. How to Protect VBA Code Picture 17
    Compile your code. (In the Visual Basic Editor, look under the "Debug" menu and select "Compile VBA Project.")
  8. How to Protect VBA Code Picture 18
    Save a copy of the file in a standard file type.
  9. How to Protect VBA Code Picture 19
    Go to "Tools" in the Visual Basic Editor, then select "Project Properties."
  10. How to Protect VBA Code Picture 20
    Select the "Protection" tab.
  11. How to Protect VBA Code Picture 21
    Activate the "Lock Project for Viewing" check box. (You may also need to set a password, depending on the specific file type you're working with and your settings for MS Office and your computer.)
  12. How to Protect VBA Code Picture 22
    Open the "Save As�" or "Save a Copy" dialog box.
  13. How to Protect VBA Code Picture 23
    Access the drop-down menu and change the file type to the appropriate type of add-in.
    1. Save a Microsoft Word add-in as a DOT file, a document template. (If you want the add-in to run when you start Word, save it in the Word Startup folder.)
    2. Save a Microsoft Excel add-in as an XLA file.
    3. Save a Microsoft Access add-in as a MDE file, which will protect the VBA code. (Microsoft Access add-ins can also be saved as MDA files, but this doesn't hide the code.)
    4. Save a Microsoft PowerPoint add-in as a PPA file which will hide the VBA code and leave it unable for anyone other than you to access it or edit it.
  14. How to Protect VBA Code Picture 24
    Quit and reopen Microsoft Office. Your add-ins should now be usable.
5 ★ | 2 Vote

May be interested

  • How to customize the Windows 10 PIN code limitHow to customize the Windows 10 PIN code limit
    setting pin windows 10 is one of the methods to protect computers safely and effectively. however, the pin will be limited to a minimum of 4 characters and a maximum of 10 characters. so how to adjust the short, long for windows 10 pin code.
  • What is Protect Battery on Samsung phones? Should I use it?What is Protect Battery on Samsung phones? Should I use it?
    all smartphones have lithium-ion batteries with a defined lifespan, measured by the number of full charge/discharge cycles the battery can go through before it begins to degrade. the average lifespan of a typical li-ion battery is about 300 to 500 charging cycles, or about two to three years.
  • The 'battlefield code' and job opportunities for youThe 'battlefield code' and job opportunities for you
    follow quantrimang with a list of websites that host 'useful playgrounds' for the coder to hunt for bonuses or get yourself a great job.
  • 9 tips to help you write 'more delicious' code9 tips to help you write 'more delicious' code
    writing code is obviously the first task if you are a software developer. however, have you ever thought your code was really good?
  • Forgot the TV PIN to get back?Forgot the TV PIN to get back?
    many users put pin code for tv but after a while do not remember the password to enter. in this case how do you handle it to retrieve tv pin code? below, network administrator will guide you how to find it extremely easily.
  • What is QR Code and how to use it?What is QR Code and how to use it?
    what is qr code and how do i use it? when buying an item, we often see a large square icon with many squares lined up in strange techniques like the matrix printed on the product packaging, which is called qr code . so qr code
  • Summary of GTA V code, GTA V cheatSummary of GTA V code, GTA V cheat
    with gta v code, you will be able to summon a vehicle, which helps the character in the game to have special abilities
  • What is VENOM Vulnerability? How can you protect yourself?What is VENOM Vulnerability? How can you protect yourself?
    the venom vulnerability affects all major cpu vendors, including intel, amd, and arm. venom allows malicious actors to read the contents of a computer's memory and potentially execute code remotely.
  • YBA code, the latest Your Bizarre Adventure codeYBA code, the latest Your Bizarre Adventure code
    code in yba will require gamers to be eligible to be able to enter the code. specifically, the player's reputation point must be enough to receive gifts from the code.
  • 4 best QR code generator tools for PDF4 best QR code generator tools for PDF
    if you're trying to share a document but want to keep all images, formatting, fonts, etc. intact, then a pdf is the way to go. but did you know that you can also share an entire pdf file from a qr code?