drom
Well-known Member
- Joined
- Mar 20, 2005
- Messages
- 543
- Office Version
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
Hi and thanks in advance
Is it possible to know if a Excel file is password protected without opening the file ?
I have the following code:
but when the file is so big takes too long and since I have to open the File always...
I am trying to avoid the checking using the above macro.
I mean is there any way of checking if a file is password protected without opening the file
Is it possible to know if a Excel file is password protected without opening the file ?
I have the following code:
Code:
Sub PasswordProtected()
On Error Resume Next: Application.ScreenUpdating = False
Dim rWorkBook As Range: Set rWorkBook = Range("rWorkBook")
Dim wFxFN As String: wFxFN = rWorkBook
Err.Clear
Debug.Print Now
Dim xlApp As Excel.Application: Set xlApp = CreateObject("Excel.Application")
Dim xlBook As Excel.Workbook: Set xlBook = xlApp.Workbooks.Open(Filename:=wFxFN, UpdateLinks:=False, ReadOnly:=True, Password:="")
If Err() = 1004 Then MsgBox "Password Protected"
xlBook.Close
xlApp.Quit
Debug.Print Now
End Sub
but when the file is so big takes too long and since I have to open the File always...
I am trying to avoid the checking using the above macro.
I mean is there any way of checking if a file is password protected without opening the file