?
Solved

VBA - skip files that are password protected

Posted on 2011-09-08
8
Medium Priority
?
397 Views
Last Modified: 2012-05-12
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
Comment
Question by:ClayCanvas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 16

Accepted Solution

by:
carsRST earned 1500 total points
ID: 36503582
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
 

Author Comment

by:ClayCanvas
ID: 36503726
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
 
LVL 16

Expert Comment

by:carsRST
ID: 36503761
When I run that code, I do not get a password box.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:carsRST
ID: 36503772
see sheet.
pwtest.xls
0
 
LVL 16

Expert Comment

by:carsRST
ID: 36503785
Wait...mine is not shared.  Let me try that.

sorry...
0
 
LVL 16

Expert Comment

by:carsRST
ID: 36503801
I get same result.  
0
 

Author Comment

by:ClayCanvas
ID: 36504435
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
 

Author Closing Comment

by:ClayCanvas
ID: 36510483
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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 use longer labels with horizontal bar charts instead of the vertical column chart.

764 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