Results 1 to 19 of 19

Protected Workbooks and VBA to Unlock Them

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-01-2018
    Location
    Maine
    MS-Off Ver
    2010
    Posts
    114

    Protected Workbooks and VBA to Unlock Them

    Hello,

    I am at stuck with a VBA code or a workaround and would greatly appreciate any help... if its even possible with Excel. I have a list of passwords and Workbook names in a 'Master' workbook. The data is on a sheet called 'Passwords'. Column A in the 'Passwords' sheet lists some Workbook names and column B contains passwords to open the workbook. All of the password protected workbooks will stay in the same folder as the 'Master' Workbook.

    Essentially I am trying to figure out a VBA script that will search the 'Passwords' sheet. Match it up to the corresponding workbook. Unlock the workbook. And Wait.

    Separately there needs to be a code that will run that in reverse. Search 'Passwords' and replace the password on the protected workbook. This is so other macros can run through the now unlocked workbooks and then once finished, lock them again.

    I found a code through other research but it seems to not do anything when I click and im not sure this is exactly what I am needing.

    Sub Robot()
    
    Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Passwords")
    Dim Loc As String: Loc = "C:\Users"
    Dim pw As String, fn As String, cb As Workbook, i As Long
    
    'Loc = Local Location
    'pw = Password
    'fn = File Name
    'cb = Current Book
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
        For i = 2 To ws.Range("A" & ws.Rows.Count).End(xlUp).Row
            On Error Resume Next 'If book does not exist
                fn = Loc & ws.Range("A" & i)
                pw = ws.Range("B" & i)
    
            On Error GoTo 0
        Next i
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    
    End Sub

    Again, any help is greatly appreciated. Even if there is another way next to VBA I am open to it. It is taking to much time to start a macro (not included here) and be prompted on every workbook to enter a password. The macro errors out if you mistype the password or similar and simply takes awhile every morning when we run it. It would be a huge time saver to allow VBA to unlock them all.
    Last edited by Darkcloud617; 10-28-2019 at 04:17 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How do i unlock protected worksheets?
    By jamesbialek in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-06-2005, 12:05 PM
  2. How do I unlock a protected worksheet
    By Michael in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 11:05 AM
  3. How do i unlock protected worksheets?
    By jamesbialek in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  4. 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

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