+ Reply to Thread
Results 1 to 7 of 7

VBA macro to unlock password protected workbook and worksheet

  1. #1
    Registered User
    Join Date
    07-23-2022
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    8

    VBA macro to unlock password protected workbook and worksheet

    Hi,

    I received such files every month:
    Sales_China.xlsm
    Sales_India.xlsm
    Sales_Korea.xlsm

    All these files are password protected. The password is stored in another file in the following format:

    Column A Column B
    China jUhI
    India ruOp
    Korea uEws

    The sheets in the file I receive are protected with 'abcd123'. This is the same for all files.

    How do i write a macro such that if the file contains values that match Column A in the file with the passwords, unlock the file with the respected password and save the file as .xslx.

    The ultimate goal is to save all the file as .xlsx. I receive 50+ such files and so doing it manually is a bit tedious.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,987

    Re: VBA macro to unlock password protected workbook and worksheet

    Something along these lines, perhaps
    Rather than try and associate the file with a password, I just tried all the passwords until one worked.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-23-2022
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    8

    Re: VBA macro to unlock password protected workbook and worksheet

    Hi,

    Thanks for this.

    I should have been more clear.

    There are 2 types of files: one is the .xlsm (Sales_China.xlsm ) that I receive and the other is one which contains list of countries and their respective passwords

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,987

    Re: VBA macro to unlock password protected workbook and worksheet

    Put the xlsm files in their own folder, open the one with the passwords, paste the code (changing the path) and run.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA macro to unlock password protected workbook and worksheet

    Place this code in the Password File...Assumes all files have passwords allocated...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 04-16-2024 at 03:46 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Registered User
    Join Date
    07-23-2022
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    8

    Re: VBA macro to unlock password protected workbook and worksheet

    Thanks for this!

    But unfortunately when the code runs, its opens up the .xlsm and requires me to input the pw myself and doesnt save as .xlsx

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA macro to unlock password protected workbook and worksheet

    Quote Originally Posted by skatey View Post
    Thanks for this!

    But unfortunately when the code runs, its opens up the .xlsm and requires me to input the pw myself and doesnt save as .xlsx
    Have no idea what you are referring to...and if you are even making use of the code in it's proper context as explained...Works as it should from our side...
    I suggest upload a few sample files to make use of... as testers...

+ 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. [SOLVED] Unlock workbook/worksheet unknown password
    By vcastro458 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2023, 10:21 PM
  2. [SOLVED] How to unlock protected workbook - Forgot password
    By ax2018 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2018, 09:53 PM
  3. Password Protected Encrypted Workbook.... Need to Unlock
    By lorber123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2016, 11:41 PM
  4. Unlock a password protected WORKBOOK
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-02-2015, 11:31 AM
  5. How to unlock the password protected sheet using macro
    By Jeffri in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2014, 07:25 AM
  6. Marco to unlock my password protected workbook.
    By 11linc11 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2013, 07:44 PM
  7. [SOLVED] How do I unlock a protected worksheet:password protected
    By Terry Swift in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2005, 09:05 PM

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