PDA

View Full Version : Solved: Process All Workbooks in a Given Directory Folder



Pool Master
01-23-2008, 11:54 AM
Hi Everyone,

This is my first post and I've only been writing macros for a couple of months, so please bare with me if my inquiry is unclear.

I'm using Application.FileSearch and Workbooks.Open to open multiple workbooks and perform the same action on each of them. My macro works just fine if there are no workbooks with passwords, however in this case some of these workbooks are password protected. I need the macro to skip any workbook that has a password and move on to the next. Any help is highly appreciated.

Thank you!
Adam

Bob Phillips
01-23-2008, 01:40 PM
Not tested, but this might work


Set wb = Nothing
On Error Resume Next
Set wb = Workbook.Open(filename)
On Error Goto 0
If Not wb Is Nothing Then
...

Pool Master
01-24-2008, 09:22 AM
xld. That suggestion was almost perfect! All I had to do was add WriteResPassword="" and Password="" to create the runtime error for the Workbooks.Open.

Thank you so much for your help!
Adam

lynnnow
01-24-2008, 10:50 PM
Don't forget to mark your thread solved when you get the perfect reply.