|
-
Dec 5th, 2005, 07:26 AM
#1
Thread Starter
Member
-
Dec 5th, 2005, 08:13 AM
#2
Frenzied Member
Re: Check for protected Excel files
http://www.exceltip.com/st/Check_if_...Excel/500.html... Let the application open a workbook and let it check via the url source.. (I've decided to put the url up instead of the source)
-
Dec 6th, 2005, 12:52 AM
#3
Thread Starter
Member
Re: Check for protected Excel files
Hi Devion, you didn't understood my question. In your code you are checking whether the code module protection in the active document. But the document (or an excel file) becomes active document only after you opened it. If the file is password protected (where in it asks for the password as soon as you open the file) then it requires user interaction. Which I want to aviod. So basically I want to check the status of a file say xxx.xls with out firing application.open(xxx.xls).
-
Dec 6th, 2005, 06:58 AM
#4
Re: Check for protected Excel files
Moved to Office Development.
-
Dec 7th, 2005, 03:25 AM
#5
Re: Check for protected Excel files
 Originally Posted by mvadu
Hi, is there any way to check for protection status of a excel file before you open it. I am running a batch process on all excel files in a folder with out any user interaction, and if any of the file is password protested then I want to simply skip that file without opening it :sick: Because these files ask for the password as soon as I try to open them, thus requiring user interaction. :eek2:
Hi,
Use the following code.
VB Code:
Sub OpenFile()
On Error GoTo ErrOpenFile
'Here the File1.xls is password protected; We are not providing
'the valid password here. So we will be getting an error.
'The error number will be 1004 in case of any issues when
'opening the file
Workbooks.Open Filename:="c:\temp\File1.xls", Password:=""
Workbooks.Open Filename:="c:\temp\File2.xls", Password:=""
ExitHere:
Exit Sub
ErrOpenFile:
If Err.Number = 1004 Then
'notify the user that "There is an issue when opening a file."
MsgBox "The file is password protected."
'To Continue with next file
Resume Next
End If
End Sub
Let me know if this code is not solved your issue.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|