• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 443
  • Last Modified:

VBA - skip files that are password protected

Hello,

I have a macro that cycles thru a group of Excel files inside a folder and makes updates.  A small number of the files are password protected.  I don't need to update the password protected files.  One issue I have right now is I'm not able to get rid of the pop up that requests the password.  When a file is password protected, I'd like to be able to identify it's password protected (or that I wasn't able to open it) and then move on.  How would you suggest I go about accomplishing this?  I'm just looking for the code right around the workbook open statement.  

I'm currently using Excel 2003.

Thanks for your help,

Steve

0
ClayCanvas
Asked:
ClayCanvas
  • 5
  • 3
1 Solution
 
carsRSTCommented:
Function hasPW(ByVal path As String) As Boolean
On Error Resume Next
Workbooks.Open path, Password:=xxx
If Err.Number > 0 Then
    hasPW = True
Else
    hasPW = False

End If


End Function
0
 
ClayCanvasAuthor Commented:
Thanks for your feedback.  I think that would work well but I seem to still have one issue remaining.  I don't seem to be able to suppress the pop up request for password.  It's a shared workbook that's password protected if someone wants to make changes or they're given the option to click a button to open "read only".

Thanks,

Steve
0
 
carsRSTCommented:
When I run that code, I do not get a password box.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
carsRSTCommented:
see sheet.
pwtest.xls
0
 
carsRSTCommented:
Wait...mine is not shared.  Let me try that.

sorry...
0
 
carsRSTCommented:
I get same result.  
0
 
ClayCanvasAuthor Commented:
you mentioned you get the same result in your last post.  Does that mean you're also getting a pop up requesting the password or does that mean getting the same result you initially received when you did not get a pop up?  

For some reason when I use the function you provided I'm still getting a pop up that's providing me with two options... enter a password or click the "Read Only" button.

Thanks,

Steve
0
 
ClayCanvasAuthor Commented:
Thanks for the idea regarding the function to open the workbooks and determine whether or not a workbook was open.  For some reason I'm not able to stop the password pop up from showing up.  I'll post a new question and see if someone has an idea as to how I can keep the password input box from showing up.

Steve
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now