Solved

Excel macro - Save & PW Protect workbooks using range w/file path names&pws

Posted on 2013-11-05
3
322 Views
Last Modified: 2013-11-06
I have the need to make changes to 64 excel 2010 workbooks located in various folders in a directory. These workbooks and their worksheets are password protected. The sheets are all protected with the same pw, the workbook protection passwords change. I store the full path/filename in column "A" of a workbook where I start the macro. It's sheet is called 'Wbklist'.  I store the workbook password in Column "B". I've pieced together a routine that I'd like to use to open each sheet and make the same correction to each sheet or poll the data within. The macro loops through each sheet in column A and unprotects the workbook and sheets. After the changes or polling is done, I cant seem to lock the workbooks back down again. The worksheets are being password protected just fine, the workbook is not. Ive tried a million little things and I dont know what Im doing wrong. When I open an individual workbook after its run, the workbook is not passwork protected.

Thanks in advance for your assistance!
PW-Protect-Quest.txt
0
Comment
Question by:socallilly
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Harry Lee
Comment Utility
socallilly,

I think you have some error on your macro.

1) in your
            Set WBSsource = Workbooks.Open(FileNames(i, 1), _
                                           ReadOnly:=False, _
                                           Password:="")

Open in new window

You already have the file opened. and you don't need to open it again in
                With WBSsource
                    '---Unprotect WB and sheets and unhide all----
                    Workbooks.Open Filename:=FileNames

Open in new window


I have modified you code a little so that I don't have so many sheets per file, and the WB protect works just fine.

Which version of Excel are you using?


Have you tried change

WBSsource.Protect FilePW, Structure:=True, Windows:=False

to Activeworkbook.Protect FilePW, Structure:=True, Windows:=False
0
 
LVL 12

Accepted Solution

by:
Harry Lee earned 500 total points
Comment Utility
Found your problem.

In the line

WBSsource.Protect FilePW, Structure:=True, Windows:=False

You have to do

WBSsource.Protect FilePW(i, 1), Structure:=True, Windows:=False

To call up the array for each password.
0
 

Author Closing Comment

by:socallilly
Comment Utility
THANKS SO MUCH HARRY!!!!! I LOVE YOU!!!!!!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now